Text::CSV_XS does not properly handled a escaped sep_char if it is the
only item in a data field.
i.e. if sep_char => ',' and escape_char => '\\' and data is
'testing,\,,fields' data will show up as 4 columns instead of 3.
However, this is remedied if the escape_char is double used inside a
column with only the sep_char in it
i.e. if sep_char => ',' and escape_char => '\\' and data is
'testing,\\,,fields' data will show up properly as 3 columns.
Example script below:
#!/usr/bin/perl;
use Text::CSV_XS;
use Data::Dumper;
my $csv = Text::CSV_XS->new({quote_char => undef, escape_char => '\\',
sep_char => ','});
print "Properly escaped sep_char which should show up as 4 columns
showing up as 5 columns:\n";
$csv->parse('hello,wo\\,rld,\\,,testing');
print Dumper($csv->fields())."\n";
$csv->parse('hello,wo\\,rld,\\\\,,testing');
print "Double escaped sep_char showing up correctly as 4 columns:\n";
print Dumper($csv->fields());
__END__
From testing it makes no difference what escape and sep chars are, the
problem still exists.
This queue is for tickets about the Text-CSV_XS CPAN distribution.
Report information
The Basics
People
Owner:
Nobody in particular
Requestors:
adam.botbyl [...] revsolns.com
Cc:
AdminCc:
BugTracker
Severity:
Normal
Broken in:
0.93
Fixed in:
0.95
This service runs on Request Tracker, is sponsored by The Perl Foundation, and maintained by Best Practical Solutions.
Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.