[wplug] awk help
chris.romano at verizon.net
chris.romano at verizon.net
Fri Aug 27 17:02:33 EDT 2004
>
> From: duncanhutty at comcast.net
> Date: 2004/08/27 Fri PM 04:48:01 EDT
> To: General user list <wplug at wplug.org>
> Subject: [SPAM] Re: [wplug] awk help
>
> How about:
> First apply a sed transformation to say that any instance of a comma *inside quotes* were converted to a (pick a suitable escape sequence) and then send it through your awk and then convert all instances of that prior escape sequence back to a commas again.
> 1st sed command:
> /".*"/s/,/\\,/g
>
> Duncan Hutty
> -------------- Original message --------------
>
> > I am having some issues with parsing a file using awk. I am not sure if awk is
> > the best tool, but I do not know perl at all. I have a comma delimited file
> > that has a few fields quoted. In those quoted fields there are commas. So when
> > awk process those fields it thinks that they are seperate and not one string.
> > i.e.
> >
> > some,text,"is, in",here
> >
> >
> > awk spits out:
> > some
> > text
> > "is
> > in"
> > here
> >
> > I want it to be
> > some
> > text
> > is, in
> > here
> >
> > my awk command is:
> > `cat $1 | awk 'BEGIN{FS=","}{print
> > $1","$3",\""$5"\",\""$6"\","$7","$8","$9","$46","$49}' > output.trans`
That did not work. Unless I am reading that wrong.
sed /".*"/s/,/\\,/g filename > output
tried ...
sed /".*"/s/,/\:/g filename > output (changes all "," to ":")
sed /".*"/s/,/\\:/g filename > output (changes all "," to ":")
I will try to mess with sed though. That is a good idea.
Thanks,
Chris
More information about the wplug
mailing list