[lug] awk question

rm at fabula.de rm at fabula.de
Tue Jan 28 09:38:33 MST 2003


On Tue, Jan 28, 2003 at 08:55:52AM -0700, Harris, James wrote:
> > Alright, I have to admit that it took using Excel to come up 
> > with this one, but
> > how about importing the data into a spreadsheet, and then 
> > saving as a tab
> > delimited file? This would cause:
> > 
> > 1,2,"3,4",5  --->  1	2	"3,4"	5

This would probably be: 1       2        3,4    5
(no need to protect the ',' character here).

> 
> My gosh... The simplicity of it nearly brings a tear to my eye.  Yes, that
> would do the job quite nicely, in fact.  It's amazing what a different point
> of view will reveal.  :)
> 

Yes, using Exel instead of AWK simplifies the process ;-) 
But doesn't this just shift the problem? Unless you can be absulutely
shure that there's no '\t' caharacter in any of the fields your'e left
with the same problem (and let me tell you: allmost every time i got
data from users in CSV format there _where_ tabs in it).

> Thanks!  I think I'll still try the exercise in pain that John Koontz
> suggested since I'd ultimately like to automate this... But your
> recommendation will help me get the initial meat-n-potatoes out today.

Probably the most stable/secure way to go will be using Perl's CSV-
Module (see other postings). It comes with the neccessary state machine
needed for parsing such data.

  hth Ralf Mattes
> Thanks for the suggestion!
> Jim
> _______________________________________________
> Web Page:  http://lug.boulder.co.us
> Mailing List: http://lists.lug.boulder.co.us/mailman/listinfo/lug
> Join us on IRC: lug.boulder.co.us port=6667 channel=#colug



More information about the LUG mailing list