Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Parsing a text file without newlines

by rev_1318 (Chaplain)
on Dec 14, 2004 at 11:22 UTC ( [id://414678]=note: print w/replies, xml ) Need Help??


in reply to Parsing a text file without newlines

I can't see anything wrong with this code-sample. Is $/ redefined somewhere in the code we don't see?
Otherwise, My guess would be, that your data originated from *nix or MacOS and you are using a Windows-environment when parsing the file.
If so, make sure you transfer the file as a text-file, not a binairy one.

Paul

  • Comment on Re: Parsing a text file without newlines

Replies are listed 'Best First'.
Re^2: Parsing a text file without newlines
by existem (Sexton) on Dec 14, 2004 at 12:04 UTC

    well i'm running the script on a linux machine, but i'm guessing the csv file was probably created on windows and has some funny windows encoding or something like that...?

    I tried using Text::CSV_XS

    my $csv = Text::CSV_XS->new({ 'quote_char' => '"', 'escape_char' => '"', 'sep_char' => ',', 'binary' => 1 });

    I changed binary to 1 and that solved a similar problem I had with another csv file, but hasn't made a difference to this file.

    Is there a setting somewhere for different types of files, like those created on windows or those from unix?

      It sounds like you need to set the eol flag. Look at the file in a hex editor to find out what the line endings really are (your editor may hide some things) or else just experiment with eol set to \012 or \015\012 or \015.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2024-04-25 17:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found