Free CSV to TAB?
February 28, 2008 4:19 PM   Subscribe

Converting CSV to TAB: is there a free software for this?

I'm a non- programmer type, and i only know the real expensive soft CSV2TAB. Any free alternatives? It's for a file where each of 4.000 lines contains two terms separated by a comma, which I'd like replaced by a tab.
thanks !
posted by Oneirokritikos to Computers & Internet (13 answers total)
 
A text editor on your platform of choice should be able to do this using the "Search & Replace" tools.
posted by majick at 4:26 PM on February 28, 2008


What platform are you on?

Perl is overkill, but can do this in a blink. It comes nicely packaged for windows and is probably pre-installed if you're on any form of *nix.

$ perl -pi -e 's/,/^V^I/' *.csv

(that's ctrl-v ctrl-i, or you can use other methods to embed the tab)

The above is crude and expects there to just be a single comma. True CSV can include commas quoted - you can expand the above to handle that but if it's outside the scope of your need ....
posted by devbrain at 4:27 PM on February 28, 2008


Best answer: There are loads of ways to do this. If nothing else, you can just open the file in Notepad, and do a search-and-replace to turn commas to tabs. (You'll need to copy and paste the tab character from another window, since you can't directly type it into the dialog box.)

You can also get the same effect by importing the file into a spreadsheet app and re-exporting it as tab-separated. There's certainly no need to spend 50 bucks on a special-purpose piece of shareware.
posted by teraflop at 4:27 PM on February 28, 2008


Or you can do this in MS Word if you have that lying around. Replace "," with "^t"
posted by adamrice at 4:34 PM on February 28, 2008


Perl is overkill. Don't confuse the issue. This can be done in any text editor, even notepad.
posted by dmd at 4:52 PM on February 28, 2008


Nonono. Search and replace is terrible.

Five lines of Python can do this, the right way.
http://docs.python.org/lib/module-csv.html

Make a reader for your source file. Make a writer with delimiter="\t" and a new destination file. For each line from the reader, push it into the writer. Done.
posted by cmiller at 4:53 PM on February 28, 2008


Best answer: cmiller, you honestly think the type of person who would ask a question like this is going to be able to handle even five lines of python?
posted by dmd at 4:55 PM on February 28, 2008 [2 favorites]


Search-and-replace is only good if you are absolutely certain that you will never, ever have a field that contains a comma.

"one","two"
"foo","bar"
"baz,quux","xaz"
posted by cmiller at 4:56 PM on February 28, 2008


"You can also get the same effect by importing the file into a spreadsheet app and re-exporting it as tab-separated."

+1
posted by cmiller at 4:58 PM on February 28, 2008 [1 favorite]


Response by poster: Thank you all for your suggestions. All I needed was figure out how to copy a tab into the replace field...
posted by Oneirokritikos at 5:03 PM on February 28, 2008


NoteTab Light is free and better than the Notepad app that comes with Windows. Same search and replace.

Just enter a regular comma for the comma and ^T to represent a tab in the search and replace box.
posted by scarabic at 5:43 PM on February 28, 2008


I would dare suggest that your question could have been posed as, "Hey, how do I get a tab in the replace field of program ___" .... besides, perl is NEVER overkill!
posted by devbrain at 6:12 PM on February 28, 2008


Oh - BTW: You probably want to search your original CSV file to make sure there aren't any tab characters in it before doing the search-and-replace thing.
posted by Orb2069 at 6:39 PM on February 28, 2008


« Older What is a medication boost bar?   |   You never forget your first . . . designer? Newer »
This thread is closed to new comments.