I agree with Laurent_R , expanding the thought more...

This: Field1, ""Quoted String" rest of the data, presumably Field3 is here, Field4 looks odd to me. If there are unbalanced quotes in Field2 like you are showing, that could definitely cause problems. What do you think that the two sequential " characters at the beginning of Field2 mean?

The best would be if you showed a short piece of code that demo'es the exactly your problem and in this case, please specify exactly what the expected output should be. As a suggestion, I would also recommend that you import your CSV into Excel and see what it does with it. You can also use Excel as a "CSV Reference Implementation", enter in a row of data and then see what Excel generates. I have never worked for MS and I am not an Excel "fan". But I have never seen CSV-Text fail to parse something that Excel generated.

At this point, I am not sure whether we are dealing with an improper CSV format or a CSV-Text error or whatever. I have used this CSV module and gotten good results with it. The CSV format is devilishly complicated when weirdo cases are considered. It is best if we can work with a verbatim example, I would put it within <code>..</code> blocks to be sure that everybody is talking about exactly the same thing.

Update: See below post with test case from the OP and others from me. This looks like invalid CSV. With more examples of these invalid lines, I suppose an ad-hoc algorithm can be designed to "fix" the CSV before feeding it into Text-CSV.


In reply to Re: Multiple double quotes within csv by Marshall
in thread Multiple double quotes within csv by mhooper

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.