Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: The future of Text::CSV_XS - TODO

by tfrayner (Curate)
on May 28, 2007 at 22:57 UTC ( #617889=note: print w/ replies, xml ) Need Help??


in reply to The future of Text::CSV_XS - TODO

Hi,

I think that making the eol option actually honour $/ would be extremely useful, and I think your suggested API for that would work fine. As I understand it (and the current behaviour of Text::CSV_XS certainly seems to bear me out) the module only handles \015\012 and \012 as CSV line endings for parsing input. It would be tremendously helpful if \015 was also supported. I'm assuming it's not, since I've never been able to get it to work despite occasional attempts over the years. There's also a note in the POD (CAVEATS) suggesting that alternate line endings are unsupported. I'm often surprised at the number of people out there still using spreadsheet software that generates CSV files with \015 line endings. I think older Mac OS machines, and some ill-behaved Mac OSX applications are at fault (if fault it really is).

Cheers,

Tim

Update: based on the principle that every bug report should at least take a stab at giving a test case, here's what I'm talking about:

perl -MText::CSV_XS -MIO::File -e '$/="\r"; $f = IO::File->new_tmpfile +; print $f "a,b,c$/"; seek($f,0,0); $c = Text::CSV_XS->new({eol => $/ +}); print join("|",@{ $c->getline($f) })'
That should output "a|b|c", and indeed does if $/ is set to \n or \r\n. Just clearing up any possible misunderstandings :-)


Comment on Re: The future of Text::CSV_XS - TODO
Download Code
Re^2: The future of Text::CSV_XS - TODO
by Tux (Monsignor) on Nov 21, 2008 at 15:12 UTC

    A test case calls for proof :)

    use strict; use warnings; use Text::CSV_XS; $/ = "\r"; print "Testing with version $Text::CSV_XS::VERSION\n"; my $csv = Text::CSV_XS->new ({ eol => $/ }); my $str = "a,b,c$/"; open my $fh, "<", \$str or die "ScalarIO: $!\n"; if (my $row = $csv->getline ($fh)) { print join "|", @$row, "\n"; } else { $csv->error_diag; }

    Generates:

    $ perl eoltest.pl Testing with version 0.58 a|b|c|

    Enjoy, Have FUN! H.Merijn

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://617889]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (9)
As of 2014-10-21 08:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (98 votes), past polls