All the CSV to TSV tutorials are suggesting a simple:
tr ',' '\t'
though some CSVs look like this:
1,310,"IntAct,PINA"
in which case I would like to keep "IntAct,PINA"
:
1 310 "IntAct,PINA"
How could I parameterize the tr
command (or sed
, etc.) in order to do that?
I appreciate any suggestions.
Use
csvformat
fromcsvkit
:or shorter:
It will remove the quotes, as they are not needed for a
tsv
.You should be able to install
csvkit
viapip
:If
csvkit
(which I recommend) is not available, then you could use the perl Text::CSV module:If you insist on retaining the quoting (which is unnecessary, since the embedded
,
is no longer a separator), then you could do something likeUsing your CSV without heading
and Miller (https://github.com/johnkerl/miller)
gives you back