Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
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?
[msh210]: About time... last time I was right was... I don't even remember when.
[shmem]: perl -e 'warn "test$/", ^@^ '
[Eily]: well, at least it's right about warn doing the same thing as die :)
[shmem]: same with undef as last element
[msh210]: oh, good point. It's the best kind of correct
[shmem]: msh210: but I'd not call it a lie outright. That's when you do know the truth.
[msh210]: I don't have sendmail (I'm on MS Windows), so does one of you think you can report the bug?
[shmem]: msh210: 'tis about time to tell the sad truth to perl5porters - via perlbug
[msh210]: probably whoever wrote that actually knows the truth
[shmem]: msh210: you can save the perlbug text in a file and send that via your mail agent of choice

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (15)
As of 2017-04-24 12:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (439 votes). Check out past polls.