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

I am sorry to have not mentioned this earlier that, fields may be delimited with dobule quotes only on one side and may conatin commas as part of field content.

My Problem is to identify fields which were delimited only on side with double quote but may or may not have commas in them. And then to delimit them in double quotes.

regards
Ya

  • Comment on Re: Re: Need method to create Regular expression for known pattern in the middle of a line

Replies are listed 'Best First'.
Re: Re: Re: Need method to create Regular expression for known pattern in the middle of a line
by BrowserUk (Patriarch) on Feb 10, 2003 at 11:01 UTC

    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.