in reply to Text::CSV_XS - proposed new interface

This looks highly promising. I've been using Text::CSV_XS and I've had quite a problem figuring out how to parse my files when they had embeded EOLs in the quoted fields. I was able to do this, but not in an elegent way, rather in a kludgy way that had poor error handling.

Your new interface seems like it might solve that rather nicely.

Also, how about:

$c->open_fh( \$filehandle) # use a CSV filehandle

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

Replies are listed 'Best First'.
Re^2: Text::CSV_XS - proposed new interface
by jZed (Prior) on Dec 15, 2004 at 22:41 UTC
    Yes, thanks, I probably will support filehandles as well as filenames. As for embedded newlines, the module already does (and always has) supported them. Just set binary=>1 in the call to new().
      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

        You should be using the getline() method - it gets one line of data, ignoring embedded newlines. But the new interface will do that automatically.