A few observations:

It appears from your supplied sample of data that each record has nine comma delimited fields. Although some are blank, and some of them do themselves contain commas.

Where there are commas within a field, they are always followed by a space.

There are no spaces in either side of a real comma delimiter.

From your sample, only the first field appears to exhibit the unbalanced quotes problem.

If you can confirm these observations as facts, it would allow a more generic solution to be provided?

Is it your intention to only fix up the missing quotes where they are unbalanced, or do you also want to place quotes around other fields that contain spaces and thereby make your data readable using standard csv handlers?


Examine what is said, not who speaks.

The 7th Rule of perl club is -- pearl clubs are easily damaged. Use a diamond club instead.


In reply to Re: Re: Re: Need method to create Regular expression for known pattern in the middle of a line by BrowserUk
in thread Need method to create Regular expression for known pattern in the middle of a line by Ya

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.