Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

How do I parse a CSV that can contain newlines in fields?
  • Comment on How do I parse a CSV that can contain newlines in fields?

Replies are listed 'Best First'.
Re: How do I parse a CSV that can contain newlines in fields?
by ChOas (Curate) on Apr 03, 2001 at 14:24 UTC
    Hey

    Set your input line seperator ($/) to the line
    delimiter, and then split on your field delimiter..

    Or use supersplit


    GreetZ!,
      ChOas

    print "profeth still\n" if /bird|devil/;
      Have a look at Text::CSV

      Jorg

      "Do or do not, there is no try" -- Yoda
        To elaborate: Text::CSV can do CSV parsing, but you'll need to make sure you send it the appropriate fields (using the input separator above, or whatever trick you prefer). Another piece of advice about Text::CSV: The docs mention that a certain range of characters is allowed. If a character outside that range is in the data, it will quietly not work.
(tye)Re: How do I parse a CSV that can contain newlines in fields?
by tye (Sage) on Apr 03, 2001 at 18:39 UTC

    As I recall, one of the reasons that tilly wrote Text::xSV was because Text::CSV doesn't handle newlines inside of quoted fields.

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