Articles

convert pipe delimited text to csv in unix

December 21, 2012 at 20:13:45
Specs: Windows 7

hi, need your advice here. i'm still new to this. i have a pipe delimited text file and want to convert to csv. the problem is whenever the data got comma (,) it will convert to next field.

example:

txt file
i like to eat burger, chicken wing and fries|i like to drink coke

output should be
i like to eat burger, chicken wing and fries<next field>i like to drink coke

but somehow, the output in csv become

i like to eat burger<next field> chicken wing and fries<next field>i like to drink coke


command use
cat test.txt | tr "|" "," > test.csv

can someone help me?


See More: convert pipe delimited text to csv in unix

Report •


#1
December 22, 2012 at 07:36:37

Can you use sed or awk to remove the commas before you convert the file?

How do you know when a politician is lying? His mouth is moving.


Report •
Related Solutions


Ask Question