in reply to Text::CSV_XS and line-endings

Sorry to get into this late, it always seems like the postings I most need to see happen when I am taking a break from PM. (maintainer of Text::CSV_XS here). The module handles MAC line endings fine, just specify eol="\015" either globally or per table. I should probably revise the dcos.

update:I originally mentioned "csv_eol" but that's the syntax for DBD::CSV, not Text::CSV_XS, it is now shown correctly as "eol"

Replies are listed 'Best First'.
Re^2: Text::CSV_XS and line-endings
by friedo (Prior) on Mar 17, 2006 at 19:33 UTC
    Hi, jZed, thanks for your reply.

    I'm trying the simplest test case I could think of, but I can't get your suggestion to work. Here is what I'm trying.

    #!/usr/bin/perl use strict; use warnings; use Text::CSV_XS; use Data::Dumper; use IO::File; my $fh = IO::File->new; $fh->open( "<test.csv" ) or die $!; my $c = Text::CSV_XS->new( { binary => 1, csv_eol => "\015" } ); my $d = $c->getline( $fh ); print Dumper( $d );

    And test.csv contains:

    foo,bar,baz^Mred,green,blue^Mnarf,blatz,quux

    (Where ^M's are \r's)

    That script results in $d being undef, as reported by Data::Dumper. Running the script on the same data with \n's instead of \r's works fine.

      Ooops, sorry, I was giving you DBD::CSV instructions, not Text::CSV_XS instructions, use "eol=>" instead of "csv_eol=>".
        I'm afraid that still gives me the same result. :(