Re: sed search and replace

From: Ed Morton (morton_at_lsupcaemnt.com)
Date: 07/25/05


Date: Mon, 25 Jul 2005 16:31:50 -0500

William James wrote:
> oraustin@hotmail.com wrote:
>
>
>>I have a CSV file which I created by concatenation of multiple files.
>>In some of the files the fields are also delimited with double quotes.
>>123,ouahfds,12341
>>"123,"fsdfsd,ewfdw",14324
>>
>>I'd like to double quote all the fields. Not sure how to achieve this
>>- please help
>>Thanks
>>Oliver
>
>
> The data in a field in a csv file is allowed to contain anything:
> commas, double-quotes, linefeeds, zero bytes.

Then does this line mean:

        a,"b,",c",d

fields:

        a
        "b,",c"
        d

or fields:

        a
        "b,"
        c"
        d

or something else?

Williams awk script converts that line to this:

        "a","b,","c","d"

which is either adding a ," in the middle of the second field (if the
correct interpretation is the first form above) or deleting the " that
follows c in the input file if it's the second form above.

Chris's shell script converts that line to:

        "a","b,","c"","d"

which means it's treating it like the second set of fields above.

Anyone know what the correct output should be and why?

        Ed.