Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
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);


Comment on Re: Import CSV to Database
Download Code

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 studying the Monastery: (13)
As of 2014-09-02 18:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (29 votes), past polls