tab-delimited to csv

Roland Smith rsmith at xs4all.nl
Mon Feb 16 09:55:59 PST 2009


On Mon, Feb 16, 2009 at 11:55:50AM -0500, John Almberg wrote:
> Can anyone suggest a way to convert a tab-delimited file to csv using  
> standard unix utilities? I could whip up a Ruby script to do it, but  

As long as the files don't contain commas themselves, it is a
straightforward sed or perl command: replace '\t' with '","'
And any field has internal double quotes, it becomes more
difficult. See http://en.wikipedia.org/wiki/Comma-separated_values

> I hate to reinvent the wheel.

I'd whip up that script. There is a shareware tab2csv utility for
windows for $49.95: http://www.download32.com/info-pack-com-tab2csv-i31827.html

OTOH, if you have a spreadsheet program like Gnumeric or OpenOffice
installed, you might be able to script those to import from tab-delimited
and export to CSV. Admittedly that is like using a nuke to kill a fly.

Roland
-- 
R.F.Smith                                   http://www.xs4all.nl/~rsmith/
[plain text _non-HTML_ PGP/GnuPG encrypted/signed email much appreciated]
pgp: 1A2B 477F 9970 BA3C 2914  B7CE 1277 EFB0 C321 A725 (KeyID: C321A725)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20090216/66205148/attachment.pgp


More information about the freebsd-questions mailing list