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

Hi,

Can anyone tell me someway of parsing delimted data that can look something like this:

"aoeuaoeu", "aoeu""
aoeuaoeu", 1
The above has 3 fields, the 2nd of which contains an escaped quote and a newline.

So, fields may or may not be quoted, may contain escaped quotes, may contain new lines.

Any suggestions?

R.

--

Robin Bowes | http://robinbowes.com

Replies are listed 'Best First'.
Re: Matching "hard" delimited files
by sauoq (Abbot) on Oct 29, 2005 at 01:07 UTC

    Try Text::xSV. IIRC (and I may not) needing to handle embedded returns was one of reasons tilly wrote it.

    -sauoq
    "My two cents aren't worth a dime.";
    
Re: Matching "hard" delimited files
by jZed (Prior) on Oct 29, 2005 at 02:48 UTC
    Text::CSV_XS will handle embedded quotes and newlines just fine. If you prefer a DBI approach, DBD::CSV does also.
Re: Matching "hard" delimited files
by Zaxo (Archbishop) on Oct 29, 2005 at 00:52 UTC

    Check the CSV modules. Some don't handle the quoted newline correctly, but some do.

    After Compline,
    Zaxo