Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^3: Text::CSV_XS - proposed new interface

by freddo411 (Chaplain)
on Dec 16, 2004 at 18:41 UTC ( [id://415427]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Text::CSV_XS - proposed new interface
in thread Text::CSV_XS - proposed new interface

As for embedded newlines, the module already does (and always has) supported them. Just set binary=>1 in the call to new().
Yes that's true, but my script is grabing and reading line by line, so that when I grab line one, I get data from the begining of the line up until the first EOL, which might be in a quoted field, not the true EOL.

My kludge is to catch this error, append the next line to the first, and try again. Do this until the line parses correctly.

That algorythm works out OK until there is a malformed data file. Now my program doesn't die until the whole file is thru an attempted read.

I think the new interface will let me catch the error on a specific line read, which is a net win for me.

Cheers

-------------------------------------
Nothing is too wonderful to be true
-- Michael Faraday

Replies are listed 'Best First'.
Re^4: Text::CSV_XS - proposed new interface
by jZed (Prior) on Dec 16, 2004 at 19:40 UTC
    You should be using the getline() method - it gets one line of data, ignoring embedded newlines. But the new interface will do that automatically.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (5)
As of 2024-04-25 07:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found