in reply to Re (tilly) 1: parsing CSV file with embedded commas (fortunately, fixed-width) - is unpack the solution?
in thread parsing CSV file with embedded commas (fortunately, fixed-width) - is unpack the solution?

Actually, I'm more interested in how it could handle the unescaped embedded comma in one of the fields.

If only splitting (or Text::xSVing) would handle that extraneous comma, i could worry about stripping off the quote marks later. It was the combination the unescaped embedded comma, the unescaped embedded quote, and the fact that only some fields were marked off in quotes that led me down the road to unpack.

  • Comment on Re: Re (tilly) 1: parsing CSV file with embedded commas (fortunately, fixed-width) - is unpack the solution?

Replies are listed 'Best First'.
(tye)Re6: parsing CSV file with embedded commas (fortunately, fixed-width) - is unpack the solution?
by tye (Sage) on Nov 01, 2001 at 04:25 UTC

    Embedded commas aren't a problem for CSV. The whole point of putting quotes around fields in the CSV is so that embedded commas can be dealt with. Embedded quotes aren't a problem if they are escaped (by doubling them).

    If you are curious how this is done, then I encourage you to download Text::CSV and/or Text::xSV (or just look at Text::xSV locally) and look for yourself. (:

            - tye (but my friends call me "Tye")