[H-GEN] Converting csv file to tab delimited text file

Clinton Roy clinton.roy at gmail.com
Wed Jun 7 00:12:19 EDT 2006


Hi Kelvin,

> hi guys,
> I am writing scripts using bash shell in cygwin. Right now, I have a set of
> raw data that is daily exported from a server into a csv format. My script
> can only process a Tab Delimited text file, so I have to open the file in
> excel and save it as Tab Delimited text file. Anyone has any alternative to
> automate this process? Please comments.

Without knowing all the details, it's impossible to give a perfectly
correct answer, however we can hopefully give you a few ideas to head
you in the right direction.

One answer is to change the IFS value, say to ', '. That might work if
you're using read to get your values in your bash script.

Another thing that comes to mind is:

sed 's/,/\t/g' input > output

But neither  method deals with any escaping issues that may be
required to handle your data, if you've got to deal with escaped
characters, use perl or python csv modules.

I kinda find it hard to believe that you can get bash shell scripts
working, but are having problems with sed :)

hope that helps,
-- 
Clinton Roy
www.acqao.org - ARC Centre of Excellence for Quantum-Atom Optics
www.humbug.org.au  - Brisbane Unix Group
azure.humbug.org.au/~croy/blog - Blog
www.flickr.com/photos/croy/ - Photos




More information about the General mailing list