replace string

I have a file almost sql ready, but some of the string are not in quotes. for example:

"ABCD", ACE, EDF, 021, ABCD, 789, 23345, "ABCD", "DEF"

my challenge is how to replace the first(1) , with , ", and
the next three(2,3,4) , as ",", and the next(5) , as ",

then every string will be quoted right, and leave the numbers as is.

thanks a lot.

Post sample of how the output should look like.

the result should look like

"ABCD", "ACE", "EDF", "021", "ABCD", 789, 23345, "ABCD", "DEF"

I think the question is how to replace only the first 5 , occurances to "," , then just replace "" to ".

thanks a lot

sed 's/ \([^"][a-Z]*\),/ "\1",/g' infile

this is definitely now working. '021' is a string, but all numbers.

---------- Post updated at 01:48 PM ---------- Previous update was at 01:39 PM ----------

i think i will just do sed 's/,/","/' for 6 times for now.

sed -e 's/ \([^"][a-Z]*\),/ "\1",/g' -e 's/[0][0-9]*/"&"/g' infile

i tried my sample file, not working. thanks verdepollo

What exactly is not working? Please provide a representative sample of your input and expected output.