tab-delimited to csv

John Almberg jalmberg at identry.com
Mon Feb 16 09:20:33 PST 2009


On Feb 16, 2009, at 12:16 PM, Adam Vande More wrote:

> 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 I hate to reinvent the wheel.
>>
>> Thanks: John
>> _______________________________________________
>> freebsd-questions at freebsd.org mailing list
>> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
>> To unsubscribe, send any mail to "freebsd-questions- 
>> unsubscribe at freebsd.org"
> if you just dealing with a few files, you could use thing like vi  
> or and editor w/ regex capbilites to search and replace tabs w/  
> comma's.
>
> perl -pe ’s/\t/,/g’ table.tsv > table.csv

There's more to csv than commas, though. For example, if one of the  
fields contains commas, you need to wrap the field with quotes.

-- John



More information about the freebsd-questions mailing list