I'm rather new to Perl, having only had an introductory course - and now I'm doing some scripts for a friend. It's been, ah, educational.

The input was a couple of files with comma-delimited records, only some of the fields had embedded commas and were enclosed in double quotes. I'd never heard of CSV, so I reinvented the wheel and got it working. I later discovered Text::CSV, figured out how to install it - and that worked on my test data - but it choked on the diacritics when I ran it on the million-plus records for the real deal. I poked around and found Text::Undiacritic and attempted to install it, then poked around some more and figured out how to force the install. Whew.

That took care of the diacritics. Now it's choking on records that look something like this:
stuff,"more","foo (1994 "bar" only)",1234,1988,3.0,""

I think the problem is in the third field - it's enclosed in double quotes and contains a parenthesized portion which in turn contains a double-quoted string.

Worst case, I could fall back on my reinvention of the wheel, but that would be cheating.

I'd appreciate very much any help.


In reply to problems parsing CSV by helenwoodson

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.