http://qs1969.pair.com?node_id=51003


in reply to Text::CSV

I to use Text::CSV quite happily. I spent forever and a day (actually, about 6 hours) trying to debug a problem with it, that was finally answered deep within the documentation. When it says:

Allowable characters within a CSV field include 0x09 (tab) and the inclusive range of 0x20 (space) through 0x7E (tilde).

It means it. In particular, if you get anything outside of this range, including any MS curly-quotes or (in my case) a single oddly out-of-range byte, it will quietly fail.

Note that it does not accept newlines inside any field either.

Replies are listed 'Best First'.
Re: Re: Text::CSV
by dilbert (Novice) on Oct 03, 2002 at 14:27 UTC
    If you use Text::CSV_XS, you can handle those characters if you turn on the 'binary' option, like this:
    use Text::CSV_XS; $csv = Text::CSV->new({binary => 1}); ... $csv->parse($_); @fields = $csv->fields();
    Really nifty if you have to parse a CSV file with French text with accented characters and newlines in it...
      Just to be nit-picky, I think that is:
      $csv = Text::CSV_XS->new({binary => 1});
      Those that pointed out that this would resolve working with text that has accents in it - I love you. I was going absolutely batty trying to deal with this text that I needed to convert to XML.


      -------------------------------------------------------------------
      There are some odd things afoot now, in the Villa Straylight.