mldvx4 has asked for the wisdom of the Perl Monks concerning the following question:
Thanks, Tux, for Text:CSV. It keeps coming in handy both directly and indirectly.
I have a question about escaped quotes in incoming files. I would have expected the output for the three data lines below to be identical, but the second line misses the escaped single quote. Is an escaped single quote some kind of faux pax or even a mistake within the data or would it be one in something which Text::CSV draws on?
#!/usr/bin/perl use Text::CSV qw(csv); use strict; use warnings; my $csv = Text::CSV->new ({ binary => 1, auto_diag => 1 }); my $o = \*STDOUT; # Read/parse CSV while (my $row = $csv->getline (\*DATA)) { my @selected = ( splice(@{$row}, 0, 2), splice(@{$row}, -6, 2) ); $csv->say($o, \@selected); } exit(0); __DATA__ 8, 9, NULL, 'Filler', '555-999', '77:88', 0, 0, 0, 0 8, 9, NULL, 'Filler', '555-999', '77:88', 'A \' B , C', 0, 0, 0 8, 9, NULL, 'Filler', '555-999', '77:88', 0, 0, 0, 0
This is based on something found in the wild.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Text::CSV and escaped quotes
by swl (Prior) on Sep 29, 2023 at 00:00 UTC | |
by mldvx4 (Friar) on Sep 29, 2023 at 00:20 UTC | |
by NERDVANA (Priest) on Sep 30, 2023 at 07:30 UTC | |
|