Subject: | Parsing failure with allow_loose_quotes + embedded newlines is correctly handled by Text::CSV_XS |
The attached reproduction script produces the following output for me. Note that the pure-Perl parser incorrectly returns two rows while the XS parser does not. If allow_loose_quotes is not enabled, both parsers return the first, expected results.
# input
"foo
loo","bar loo", baz
# Text::CSV_XS version 1.11
$row1 = [
"foo\nloo",
"bar loo",
" baz"
];
# Text::CSV_PP version 1.31
$row1 = [
"\"foo"
];
$row2 = [
"loo\"",
"bar loo",
" baz"
];
Thomas
Subject: | csv-parse-bug.pl |
#!/usr/bin/env perl
use strict;
use warnings;
use autodie;
use Data::Dumper;
use Text::CSV_PP;
use Text::CSV_XS;
$Data::Dumper::Useqq = 1;
my $input = <<'';
"foo
loo","bar loo", baz
print "# input\n", $input;
for my $impl (qw(XS PP)) {
my $class = "Text::CSV_$impl";
my $csv = $class->new({
binary => 1,
eol => $/,
allow_loose_quotes => 1,
}) or die $class->error_diag . "\n";
open my $fh, '<', \$input;
my $count = 1;
print "\n# $class version ", $class->VERSION, "\n";
while (my $row = $csv->getline($fh)) {
print Data::Dumper->Dump([ $row ], [ "row".$count++ ]);
}
}