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

Kelvin Heng kelvinheng at hotmail.com
Wed Jun 7 01:31:22 EDT 2006


alright, I guess I have the answer.

All I need to do is:

# sed 's/"//g' sample.csv > sample.txt
This command will remove all the "
So my data will be left with only data1,data2,data3,etc

am I right now?

thanks for all your help.. :p

Regards,
Kelvin Heng
Have A Nice Day!




>From: "Kelvin Heng" <kelvinheng at hotmail.com>
>To: general at lists.humbug.org.au
>Subject: Re: [H-GEN] Converting csv file to tab delimited text file
>Date: Wed, 07 Jun 2006 05:25:26 +0000
>
>[ Humbug *General* list - semi-serious discussions about Humbug and     ]
>[ Unix-related topics. Posts from non-subscribed addresses will vanish. ]
>


>I have attached the sample.csv, if you open the file using vim, you will 
>see that each field is tagged using "" and separated by ,
>
>I have no problem doing a awk using field delimitor , but do not know how 
>to remove the " without causing problem to my original data.
>
>So I find the safe way is to open using excel spreadsheet and save it as 
>tab delimited text file.
>
>Regards,
>Kelvin Heng
>Have A Nice Day!
>
>
>
>
>>From: Ted Percival <ted at midg3t.net>
>>To: general at lists.humbug.org.au
>>Subject: Re: [H-GEN] Converting csv file to tab delimited text file
>>Date: Wed, 07 Jun 2006 14:14:30 +1000
>>
>>[ Humbug *General* list - semi-serious discussions about Humbug and     ]
>>[ Unix-related topics. Posts from non-subscribed addresses will vanish. ]
>>
>>Kelvin Heng wrote:
>> > 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.
>>
>>I've never really had to deal with CSV or tab delimited files, but
>>either of the following might be close to what you're after.
>>
>>Given the file 'file' with the following contents:
>>a,b,c
>>d,e,f
>>
>>To replace the commas with tabs (presumably that's all you need), try:
>>tr , '\t' < file
>>or:
>>sed -e 's/,/\t/g' file
>>
>>You can use shell redirection to output to a file, or the non-standard
>>'-i' flag for sed to do in-place editing.
>>
>>-Ted
>>
>>_______________________________________________
>>General mailing list
>>General at lists.humbug.org.au
>>http://lists.humbug.org.au/cgi-bin/mailman/listinfo/general
>


><< sample.csv >>


>_______________________________________________
>General mailing list
>General at lists.humbug.org.au
>http://lists.humbug.org.au/cgi-bin/mailman/listinfo/general






More information about the General mailing list