Converting csv to tsv and back


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Converting csv to tsv and back
# 1  
Old 05-04-2008
Converting csv to tsv and back

Anyone have a simple UNIX script to look at for doing this? I'm interested in how to convert from csv to tsv, and then back again, if I want to.

Thanks!
# 2  
Old 05-04-2008
man sed

hint: escape sequence for tab is \t
# 3  
Old 05-04-2008
Thanks.

When I do: sed 's/,/\t/g' test
it doesn't go to tabbed. It just eliminates spaces...?
# 4  
Old 05-04-2008
Your pattern is right. It should work as expected (and does here on Linux, just tested). Use like
Code:
cat file.csv | sed 's/,/\t/g' > file.tsv

# 5  
Old 05-04-2008
Older versions of sed don't recognize \t as a tab, type ctrl-m and a tab instead of \t.

Regards
# 6  
Old 05-04-2008
Hmmm, I have the latest version of OS X Leopard and am using BASH...but I'm guessing that may have nothing to do with what sed version I'm running? (Sorry, quite new to this).
# 7  
Old 05-04-2008
What does
Code:
sed --version

say?
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Converting XML to CSV

Hello, For i while i have been using XMLStarlet to convert several XML files to CSV files. So far this always went fine. Today however i got a new XML format however but i cannot find out how to get the data i need. Below is part of the code where it shows the different format. What... (10 Replies)
Discussion started by: SDohmen
10 Replies

2. Shell Programming and Scripting

Converting csv to html format

Below is the code I have - How can I convert the data in the csv into 3 tables in html. instead of 1 table. Attached is the format I am getting. (1 Reply)
Discussion started by: archana25
1 Replies

3. Shell Programming and Scripting

Converting CSV to ascii format

Hej All, I have a file like this which is a comma dilimited: input: 6000318,-263.011520678,-59.05869872409,587.67924868792 6000319,-265.6996842902,-50.24902479999,590.65693082607 6000320,-238.1333898366,-288.801232595,633.75332173496... (5 Replies)
Discussion started by: Johanni
5 Replies

4. Shell Programming and Scripting

awk with tsv & csv

Hi! HELP! I have a few issues... I have a tsv with headers time, binary time, bytes, and bits. I'm trying to extract only time & bits. (Trying to graph throughput) Using: awk -F"\t" '{print $1, "\t"$4}' infile.tsv > outfile.tsv Output is only the headers: time bits Thinking it... (2 Replies)
Discussion started by: calitiggr
2 Replies

5. Shell Programming and Scripting

Converting txt file in csv

HI All, I have a text file memory.txt which has following values. Average: 822387 7346605 89.93 288845 4176593 2044589 51883 2.47 7600 i want to convert this file in csv format and i am using following command to do it. sed s/_/\./g <... (3 Replies)
Discussion started by: mkashif
3 Replies

6. UNIX for Dummies Questions & Answers

Converting spaces to csv

I'm new to shell scripting and I have a file with positional columns. The rows look like this: 222 3333 44444 55 55 55 55 5555 59999 222 3333 44444 55 55 55 55 5555 59999 Not every row has the same number of spaces between the seven columns. They can range anywhere... (11 Replies)
Discussion started by: jkandel
11 Replies

7. UNIX for Dummies Questions & Answers

Converting HTML to CSV

Hi, I need to convert a relatively large html file (1.5megs) into CSV under Unix. How would I be able to do this? Much thanks. (3 Replies)
Discussion started by: Jexel
3 Replies

8. Shell Programming and Scripting

converting text to csv format

I am trying to check each line and based on first two digits, the comma needs to be place. I checked in the earlier post where the text is converted to csv with a tab delimited. Here is the test file that needs to be changed to csv 11 051701 22 051701 330123405170105170112345... (13 Replies)
Discussion started by: gthokala
13 Replies

9. Shell Programming and Scripting

Converting %## back to special characters from an HTML form

I have an HTML form that sends email to a large list of users one at a time by matching an email address in peoplesoft to their username. It works great, except that special characters are converted to %## format. Is there a library of these I can use to sed them back (yes this is a crappy UNIX... (1 Reply)
Discussion started by: 98_1LE
1 Replies

10. Shell Programming and Scripting

Converting csv to xls

Hi, Can anyone tell the option to change the file type in unix. i.e. if a file is in csv(Comma Separating Values) format, it should be changed to xls(ordinary MS-Excel) format. But renaming command is not changing to correct file format. Thanks in advance, Milton. (1 Reply)
Discussion started by: miltony
1 Replies
Login or Register to Ask a Question