Skip Menu |

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

Report information
The Basics
Id: 83705
Status: resolved
Priority: 0/
Queue: Text-CSV

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

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



Subject: single allow_loose_quotes
allow_loose_quotes => 1 allows to have ;"foo";"foo"bar""; but not an uneven count of quotes like: ;"foo";"foo"bar"; Worse, this line isn't returning an error in error_diag() but just ignored or maybe merged with the previous or next. I found this by having $count++ inside while (my $row = $csv->getline($fh_file)) returning the "wc -l" minus 1. Is it possible to detect ;" and "; as the real quotes and escaping single quotes between? Is there a workaround so far to repair the cvs data on the fly with getline() without writing into new file? Best regards, Massimo The CSV line with that issue: "xx";"xx";"Privat";"";"";"PAYPAL";"-16,51";"16.05.2011";"16.05.2011";"Q52Y2X327E * MCT";"R, IHR EINKAUF BEI MCT";"1.340,47";"";"NONREF";"Computer";"2,5" FESTPLATTE";"E R, ARTIKEL 1 10513T0PT ";;"";
I created a minimal example to show the issue: #!/usr/bin/env perl use strict; use warnings; use utf8; use v5.10; use Text::CSV; my $csv_dump = q{"6RE";"EINKAUF";"5";"";"2,5" HD" "LIDL";"-2"}; my $csv = Text::CSV->new( { binary => 1, allow_loose_escapes => 1, allow_loose_quotes => 1, sep_char => q{;}, escape_char => q{"}, quote_char => q{"} } ); open my $fh, "<:encoding(utf8)", \$csv_dump; my $cnt=0; while ( my $line = $csv->getline($fh)) { $cnt++; say for @$line; say "Count:$cnt"; } $csv->error_diag; # Output: # # 6RE # EINKAUF # 5 # # 2,5 HD" # LIDL # -2 # Count:1
Fixed in the new version. https://metacpan.org/release/MAKAMAKA/Text-CSV-1.32 Thanks! On 2013-3月-04 月 08:46:45, https://www.google.com/accounts/o8/id?id=AItOawm1jrg_vpe-62yHY63URR6XcGvg55qGhDM wrote: Show quoted text
> I created a minimal example to show the issue: > > #!/usr/bin/env perl > > use strict; > use warnings; > use utf8; > use v5.10; > > use Text::CSV; > > my $csv_dump = q{"6RE";"EINKAUF";"5";"";"2,5" HD" > "LIDL";"-2"}; > > my $csv = Text::CSV->new( > { > binary => 1, > allow_loose_escapes => 1, > allow_loose_quotes => 1, > sep_char => q{;}, > escape_char => q{"}, > quote_char => q{"} > } > ); > open my $fh, "<:encoding(utf8)", \$csv_dump; > > my $cnt=0; > while ( my $line = $csv->getline($fh)) { > $cnt++; > say for @$line; > say "Count:$cnt"; > } > $csv->error_diag; > > > # Output: > # > # 6RE > # EINKAUF > # 5 > # > # 2,5 HD" > # LIDL > # -2 > # Count:1