views:

11

answers:

2

Is there a tool that can take this:

Attack,Decay,Sustain,Release
45,-1,26,55
"VERY LONG TEXT",false,true,true
0,0,1,1

and output it in a tabbed-format like this:

Attack,            Decay,  Sustain, Release
45,                -1,     26,      55
"VERY LONG TEXT",  false,  true,    true
0,                 0,      1,       1

I need it for some arrays that I'm building with CSV data, I'm currently doing it manually but wondering if there's a faster way.

Thanks

A: 
  • Save the comma separated content into a text file with .csv extension.
  • Open the csv file using excel.
  • Save the csv file as "tab separated text" file, into a new file

Or

  • Use an editor like notepad++ (any editor that has a bit advanced find/replace capability)
  • Find ",", replace with "\t" (and check the option that has a title regular expression)

Hope that helps.

shahkalpesh
Not `,`->`\t`, but `,`->`,\t`.
mbq
shahkalpesh
But your solution does not calculate how many tabs are needed based on the longest cell of the column. Only a specially created script/program can do this. See updated data in my Q.
Jenko
shahkalpesh
A: 
$ column -s, -t

This will remove the commas, but those are easy enough to put back. Perhaps something like:

$ column -s, -t < input | perl -pe 's/(\w) /$1,/g'
Attack, Decay, Sustain, Release
45,     -1,    26,      55
false,  false, true,    true
0,      0,     1,       1

Of course, this gives you space delimited output. I just re-read your question and see that you want tabs. That makes it much easier. Just do:

$ perl -pe 's/,/,\t/g' input
William Pursell