i have a file with 3 columns, the 2nd column is lat/long and may or may not have data.
2012-01-10 21:27:52.811,,ABC -- No lat/long
2012-01-10 21:27:52.811,37.8889329,-112.1876328,XYZ -- with lat long
Can some one help me with a sed/awk/perl to transform it to
2012-01-10 21:27:52.811,"37.8889329,-112.1876328",XYZ
In all other cases it should not add any double quotes
Thanks in advance
I would probably do something like this, using
awk:This assumes that the fields are comma-delimited on the way in and the way out.
If the second and third fields are populated then
"before the second field"after the third fieldPrint all lines (
1).There are a lot of assumptions here, so you’ll have to dig out the sed & awk book and tweak this to meet your needs.