Skip Menu |

This queue is for tickets about the Text-CSV_XS CPAN distribution.

Report information
The Basics
Id: 72529
Status: rejected
Priority: 0/
Queue: Text-CSV_XS

People
Owner: Nobody in particular
Requestors: uncoolbob [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



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
Subject: Re: [rt.cpan.org #72529] allow_loose_quotes not compatible with commas within quotes
Date: Fri, 18 Nov 2011 22:26:08 +0100
To: bug-Text-CSV_XS [...] rt.cpan.org
From: "H.Merijn Brand" <h.m.brand [...] xs4all.nl>
On Fri, 18 Nov 2011 11:35:46 -0500, "https://me.yahoo.com/a/ea8p8JwYnosfxSTV0Sl_xnjvkkLF#ea82b via RT" <bug-Text-CSV_XS@rt.cpan.org> wrote: Show quoted text
> 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';
s s L Ls s = sep_char L = loose quote as in this line, the third field does not *START* with a quote, all quotes inside the string are loose quotes (as you redefined the escape, there is no other choice) Show quoted text
> $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';
s s L s Ls Same here, and there is no way to have a combination of options to make that different Show quoted text
> $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';
s sq L Lqs As this field now *STARTS* with a quote, it is a quoted field. The second L is now seen as a loose quote, as it is not followed by a sep_char (and you redefined escape_char). Show quoted text
> # or with allow_loose_quotes=>0 > $string = 'abc,def,"xyz \"ghi,jkl\"",lmn';
Obviously Show quoted text
> I get the same behaviour with Text::CSV_PP.
As expected. I'll mark this as not-a-bug -- H.Merijn Brand http://tux.nl Perl Monger http://amsterdam.pm.org/ using 5.00307 through 5.14 and porting perl5.15.x on HP-UX 10.20, 11.00, 11.11, 11.23 and 11.31, OpenSuSE 10.1, 11.0 .. 11.4 and AIX 5.2 and 5.3. http://mirrors.develooper.com/hpux/ http://www.test-smoke.org/ http://qa.perl.org http://www.goldmark.org/jeff/stupid-disclaimers/
Subject: Re: [rt.cpan.org #72529] allow_loose_quotes not compatible with commas within quotes
Date: Fri, 18 Nov 2011 21:33:21 +0000
To: bug-Text-CSV_XS [...] rt.cpan.org
From: Bob MacCallum <uncoolbob [...] gmail.com>
Thanks very much. I did misunderstand the role of loose quotes - they are not treated as paired/pairable (I guess the clue is in the name). On Fri, Nov 18, 2011 at 9:26 PM, h.m.brand@xs4all.nl via RT <bug-Text-CSV_XS@rt.cpan.org> wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=72529 > > > On Fri, 18 Nov 2011 11:35:46 -0500, > "https://me.yahoo.com/a/ea8p8JwYnosfxSTV0Sl_xnjvkkLF#ea82b via RT" > <bug-Text-CSV_XS@rt.cpan.org> wrote: >
>> 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';
>                s   s    L       Ls > > s = sep_char > L = loose quote > > as in this line, the third field does not *START* with a quote, all > quotes inside the string are loose quotes (as you redefined the escape, > there is no other choice) >
>> $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';
>                s   s    L   s   Ls > > Same here, and there is no way to have a combination of options to make > that different >
>> $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';
>                s   sq    L       Lqs > > As this field now *STARTS* with a quote, it is a quoted field. The > second L is now seen as a loose quote, as it is not followed by a > sep_char (and you redefined escape_char). >
>> # or with allow_loose_quotes=>0 >> $string = 'abc,def,"xyz \"ghi,jkl\"",lmn';
> > Obviously >
>> I get the same behaviour with Text::CSV_PP.
> > As expected. I'll mark this as not-a-bug > > -- > H.Merijn Brand  http://tux.nl      Perl Monger  http://amsterdam.pm.org/ > using 5.00307 through 5.14 and porting perl5.15.x on HP-UX 10.20, 11.00, > 11.11, 11.23 and 11.31, OpenSuSE 10.1, 11.0 .. 11.4 and AIX 5.2 and 5.3. > http://mirrors.develooper.com/hpux/           http://www.test-smoke.org/ > http://qa.perl.org      http://www.goldmark.org/jeff/stupid-disclaimers/ > >