#!/usr/bin/perl
# filename: csv.pl
use strict;
use warnings;

foreach(<>){
  my ($names, $address, $rest)  = split '"';
  my ($lastname, $firstname, $waste, $city, $state, $zip)
    = (split (/,/ , $names), split(/,/ , $rest));
  print join( "\n",
    ($lastname, $firstname, $address, $city, $state, $zip)),
    "\n";
}



$ ./csv.pl < data.txt
Lastname
Firstname
Address, Apt/Suite #123
City
State
Zipcode




On 6/29/07, ankIT WALiA <[EMAIL PROTECTED]> wrote:
>
> Hi all,
>
> I want to retrive data from csv file.
> let us say record
> Lastname,Firstname,"Address, Apt/Suite #123",City,State,Zipcode
> when i split it using comma,
> it seprate out into
>
> Lastname
> Firstname
> Address
> Apt/Suite #123
> City
> State
> Zipcode
>
> but i need to store data into
>
> Lastname
> Firstname
> Address, Apt/Suite #123
> City
> State
> Zipcode
>
> I am using
> var oFile = Clib.fopen(vFilepath,"r");
> var string = (Clib.fgets(oFile));
>                         if(string)
>                         {
>                            var arr = string.split(",");
>                         }
>
> Please suggest something......
>
> Thanks
> --
> LIfe is like a Rose is upto u spreading its fragnance or thorns.
> अन्कित वालिया
> _______________________________________________
> ilugd mailinglist -- ilugd@lists.linux-delhi.org
> http://frodo.hserus.net/mailman/listinfo/ilugd
> Archives at: http://news.gmane.org/gmane.user-groups.linux.delhi
> http://www.mail-archive.com/ilugd@lists.linux-delhi.org/
>



-- 
o1p2e3n4g5l6
http://saleem.a.ansari.googlepages.com/
http://www.jmilug.org/
http://www.csijmi.com/
Linux User #414799 (http://counter.li.org/)
_______________________________________________
ilugd mailinglist -- ilugd@lists.linux-delhi.org
http://frodo.hserus.net/mailman/listinfo/ilugd
Archives at: http://news.gmane.org/gmane.user-groups.linux.delhi 
http://www.mail-archive.com/ilugd@lists.linux-delhi.org/

Reply via email to