Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Import CSV to Database

by flyboy (Novice)
on Jul 18, 2002 at 16:57 UTC ( #182908=note: print w/replies, xml ) Need Help??


in reply to Import CSV to Database

This code is from the Perl Cookbook. It returns an array.
sub parse_csv { my $text = shift; my @new = (); push(@new,$+) while $text =~ m{ "([^\"\\]*(?:\\.[^\"\\]*)*)",? | ([^,]+),? | , }gx; push(@new,undef) if substr($text,-1,1) eq ','; return @new; } # Use like so: my ( $row1, $row2, $row3, ) = parse_csv($csv_line);

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://182908]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (6)
As of 2016-10-01 21:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?






    Results (8 votes). Check out past polls.