in reply to lightweight CSV parser
As Anonymous Monk already said, parsing from strings is supported from the early days, not only by the PerlIO layer (file handles on scalars are natively supported) but also directly from strings.:
my $csv = Text::CSV_XS->new ({ binary => 1, auto_diag => 1 }); # Using ScalarIO open my $fh, "<", \$csv_stream; while (my $row = $csv->getline ($fh)) { # just like a file, but now on a string ... } close $fh; # Using strings directly. Much less reliable! foreach my $line (@csv_strings) { my @row = $csv->parse ($line); }
Don't try to rewrite a CSV parser. The de-facto parsers Text::CSV_XS and Text::CSV have been tested by millions and already have dozens of options and features as requested by the community.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: lightweight CSV parser
by wrinkles (Pilgrim) on Dec 22, 2011 at 16:22 UTC | |
|
Re^2: lightweight CSV parser
by wrinkles (Pilgrim) on Dec 22, 2011 at 20:00 UTC | |
by Tux (Canon) on Dec 23, 2011 at 09:17 UTC |