Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: A module to parse CSVs line by line with an ability to set delimiter

by Tux (Abbot)
on Mar 26, 2013 at 14:23 UTC ( #1025532=note: print w/replies, xml ) Need Help??


in reply to A module to parse CSVs line by line with an ability to set delimiter

You tried Text::CSV, which is the wrapper over Text::CSV_pp (pure perl) and the fast Text::CSV_XS. They both have the same syntax:

use Text::CSV; my $parser = Text::CSV->new ({ binary => 1, # allow binary data auto_diag => 1, # allow automatic warnings and errors sep_char => ",", # , is the default, ; is also use quite often }); open my $fh, "<", "file.csv" or die "file.csv: $!"; while (my $row = $csv->getline ($fh)) { say "The second field is ", $row->[1]; }

Enjoy, Have FUN! H.Merijn
  • Comment on Re: A module to parse CSVs line by line with an ability to set delimiter
  • Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1025532]
help
Chatterbox?
[choroba]: just one of its angles, in fact
[LanX]: <|--
[choroba]: Reminds me of an old joke about an orchestra...
erix imagines that in a true Lancs accent
[choroba]: so a Czech orchestra rehearses a new piece by a German composer
LanX LOL of the day ... the Turkish Anonymous Alcoholics stopped their "No to alcohol" campaign for political reasons ...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (8)
As of 2017-03-27 11:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (319 votes). Check out past polls.