Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

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


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).



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
Replies are listed 'Best First'.
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; }


    $ perl Testing with version 0.58 a|b|c|

    Enjoy, Have FUN! H.Merijn

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (5)
As of 2015-11-25 02:59 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (670 votes), past polls