Subject: | allow_loose_quotes not compatible with commas within quotes |
I may be misunderstanding the role of quotes in CSV, but if not, then I
may have found a bug:
use Text::CSV_XS;
$parser = Text::CSV_XS->new({allow_loose_quotes=>1, escape_char=>"\\",
quote_char=>'"', allow_loose_escapes=>1});
# this works
$string = 'abc,def,xyz "ghi;jkl",lmn';
$parser->parse($string) && print join "\n", $parser->fields();
abc
def
xyz "ghi;jkl"
lmn
# but this doesn't work (as I expect)
$string = 'abc,def,xyz "ghi,jkl",lmn';
$parser->parse($string) && print join "\n", $parser->fields();
abc
def
xyz "ghi
jkl"
lmn
# this also works, but I'd really like the previous example to work!
$string = 'abc,def,"xyz "ghi,jkl"",lmn';
# or with allow_loose_quotes=>0
$string = 'abc,def,"xyz \"ghi,jkl\"",lmn';
I get the same behaviour with Text::CSV_PP.
System info:
perl -v
This is perl 5, version 12, subversion 1 (v5.12.1) built for
x86_64-linux-thread-multi
Linux hostname 2.6.34.7-0.5-desktop #1 SMP PREEMPT 2010-10-25 08:40:12
+0200 x86_64 x86_64 x86_64 GNU/Linux
many thanks for a great module (I've used it in another project with
zero problems at all - this one has some dirtier data...)
Bob