Subject: | Text::xSV::Slurp ignores Text::CSV eol setting when reading CSV file header |
Date: | Sun, 29 Jan 2012 15:58:21 +0000 |
To: | bug-Text-xSV-Slurp [...] rt.cpan.org |
From: | Paul McDermott <pmcdermott98 [...] gsb.columbia.edu> |
Text::xSV::Slurp appears to ignore any special line endings set for the
CSV file via the 'eol' parameter to 'text_csv'.
e.g. $aoh = xsv_slurp('file.csv', text_csv => {eol => "\015\012"})
This is because in Text::xCSV::Slurp::_as_aoh() chomp is used to remove
the line ending. chomp is not aware of the eol setting. Using
$csv->getline($handle) will get the header line line and parse it, using
the 'eol' setting already passed to Text::CSV.
The patch below fixes this issue for _as_aoh(), but Text::xCSV::Slurp
may need fixing in other places.
607c607,613
< my $header = <$handle>;
---
Show quoted text
> # Should use Text::CSV::getline here to ensure that any 'eol'
spec set for
Show quoted text > # Text::CSV via 'text_csv' is used
> my $header = $csv->getline($handle);
>
> if (not defined $header and i( 0 + $csv->error_diag)) {
> confess 'Error: '.$csv->error_diag;
> }
612,619c618
< chomp( $header );
<
< if ( ! $csv->parse($header) )
< {
< confess 'Error: ' . $csv->error_diag;
< }
<
< my @headers = $csv->fields;
---
Show quoted text > my @headers = @$header;