Wednesday, 22 August 2012

Convert a Tab separated to Comma separated file

If you want to replace some text within a file, that is too large to open in a GUI application then, this is when you fall back on the command line tools.

Sometimes I get a Tab separated (.tsv/.txt) file and I need to convert it to a Comma separated (.csv) file before I can import it into a database table.

On a Linux server:
Code:   
tr -s '\t' <input | tr '\t' ',' >output
   
Substitute 'input' for the original filename and 'output' for the desired output filename.


No comments: