From: oraustin on
Firstly - is there a sed newsgroup for me to be posting to?
Quick question now :)
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

From: Alan Connor on
On comp.unix.shell, in
<1122282459.844933.97360(a)g49g2000cwa.googlegroups.com>,
"oraustin(a)hotmail.com" wrote:

> Firstly - is there a sed newsgroup for me to be posting
> to? Quick question now :) 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
>

Really? Interesting.

AC



--
People who post through google take and take and never give
back. Ever seen one of them help anyone? If they are asking
about anything but how to use a real newsreader, PLEASE DON'T
HELP THEM. -----------> news.software.readers
From: G_r_a_n_t_ on
On 25 Jul 2005 02:07:39 -0700, oraustin(a)hotmail.com wrote:

> Firstly - is there a sed newsgroup for me to be posting to?
> Quick question now :)
> 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
Revisit you concatenation and do it better, and just how will you
resolve unbalanced quotes? Your choice.

Grant.
From: John L on

<oraustin(a)hotmail.com> wrote in message news:1122282459.844933.97360(a)g49g2000cwa.googlegroups.com...
> Firstly - is there a sed newsgroup for me to be posting to?
> Quick question now :)
> 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

There is no sed newsgroup, this one is fine for sed.
That said, I am unconvinced that sed is the right tool
for this job.

CSV is a terrible format. Look at your example above:
the second line has three quotation marks: whether
that is intentional or not, clearly at least one field
includes a comma and other (unshown) fields might
include quotation marks.

I've got some code lying around somewhere to deal with
CSV files but really you should be looking for existing
tools that know about CSV. Try a perl newsgroup or even
reading your file into a spreadsheet and then re-exporting
it in the desired format.

--
John.


From: oraustin on
Firstly - Alan Connor - Why bother to post? I have no choice than to
use Google Groups. I am not knowledgable about sed but in the past have
been active in the Eiffel Newsgroup and to a much lesser extent C.
Ok back to the topic
sorry my mistake about the unbalanced quotes.
123,houlf,134
"132","housdfgd,sdfd","14324"

I could do the concatenation better - how about before concatenation if
the first character of the file is not a " then substitute , with ","
in the file - I could do with some help with the command for this.

Thanks