C
ccc31807
I have CSV file with rows that looks like this:
ROW EXAMPLE 1
fieldA,fieldB,fieldC,George,Washington,President,"1600 Pennsylvania
Avenue, Washington, D.C. 55554",202-555-1212,fieldX,fieldY,fieldZ<EOL>
I want to preserve the interior commas from the double quoted portion
of the string, perhaps turning it into something like this:
ROW EXAMPLE 2
'fieldA','fieldB','fieldC','George','Washington,President','1600
Pennsylvania Avenue, Washington, D.C.
55554','202-555-1212,','fieldX',;fieldY',;fieldZ'<EOL>
where each value is single quoted and the values are separated by
commas.
I wanted (past tense) to do this with one vi (vim) regex and spend
about an hour trying different ones before giving up in failure. I use
three different regexes to do what I wanted, so I don't have the
problem anymore, but I still have the question.
What one regex can I use (in vi/vim) to transform EXAMPLE 1 to EXAMPLE
2?
Thanks, CC.
ROW EXAMPLE 1
fieldA,fieldB,fieldC,George,Washington,President,"1600 Pennsylvania
Avenue, Washington, D.C. 55554",202-555-1212,fieldX,fieldY,fieldZ<EOL>
I want to preserve the interior commas from the double quoted portion
of the string, perhaps turning it into something like this:
ROW EXAMPLE 2
'fieldA','fieldB','fieldC','George','Washington,President','1600
Pennsylvania Avenue, Washington, D.C.
55554','202-555-1212,','fieldX',;fieldY',;fieldZ'<EOL>
where each value is single quoted and the values are separated by
commas.
I wanted (past tense) to do this with one vi (vim) regex and spend
about an hour trying different ones before giving up in failure. I use
three different regexes to do what I wanted, so I don't have the
problem anymore, but I still have the question.
What one regex can I use (in vi/vim) to transform EXAMPLE 1 to EXAMPLE
2?
Thanks, CC.