Closed shenwei356 closed 9 months ago
Added two commands:
fix-quotes
: fix malformed CSV/TSV caused by double-quotes.del-quotes
: remove extra double-quotes added by `fix-quotesTry it:
$ echo -ne "a,\"Cellvibrio\" Winogradsky 1929,c\n"
a,"Cellvibrio" Winogradsky 1929,c
$ echo -ne "a,\"Cellvibrio\" Winogradsky 1929,c\n" | csvtk fix-quotes | csvtk cut -f 1-
a,"""Cellvibrio"" Winogradsky 1929",c
$ echo -ne "a,\"Cellvibrio\" Winogradsky 1929,c\n" | csvtk fix-quotes | csvtk pretty
a "Cellvibrio" Winogradsky 1929 c
- ----------------------------- -
$ echo -ne "a,\"Cellvibrio\" Winogradsky 1929,c\n" | csvtk fix-quotes | csvtk del-quotes
a,"Cellvibrio" Winogradsky 1929,c
However, when the quotes are only in the middle of fields, theres' no problem.
According to this answer, the CSV format is not valid ~