; and parses it to another program. I want to check each field to see if it is
; blank and if so exchange the blank for two single quotes (ie: '' ).
; I am trying to use an if statement right now, but I cant figure out how to
; represent a blank.
[snip]
; What's wrong with the above picture?
well your indenting for a start. :) Seriously though, you don't want to
loop over every field like that. This is an intrinsically difficult
problem, whose difficulty varies depending on just how liberal you plan
to be as to what sort of characters can inhabit fields.
Since you haven't supplied such information, the best we can do is make
a guess. So, with that in mind, the real answer is to use something
like the Perl Text::CSV module if your goal is completeness. If you
just want something that might work for you, then try the following;
On an extremely limited data set, this seemed to work, I'm the first to
admit this isn't a complete solution, so don't bother hassling me. :)
$ sed "s/,,/,'',/g;s/,,/,/g;s/,$//" <<_
> a,b,c,e,f,g,,i,,k,,,,
> a,,b,,c,,d,,e,,f,,g
> _
a,b,c,e,f,g,'',i,'',k,'',''
a,'',b,'',c,'',d,'',e,'',f,'',g
cheers,
r.
--
SLUG - Sydney Linux User Group Mailing List - http://slug.org.au/
More Info: http://slug.org.au/lists/listinfo/slug