LibreCat / Catmandu

Catmandu - a data processing toolkit
https://librecat.org
175 stars 31 forks source link

--sep-char and "\t" chardoes not give what I excpect #358

Closed clrh closed 5 years ago

clrh commented 5 years ago

Hi,

This is my case. I would like to export a CSV file with a tabulationas separator. I don't arrive to tell it well to Catmandu:

# OK
$ catmandu convert MARC to CSV --fix test.fix --sep_char ';' < LF-1000.mrc > out.csv; more -3 out.csv
ark;id;title
http://catalogue.bnf.fr/ark:/12148/cb38873787v;775;Sangohan
http://catalogue.bnf.fr/ark:/12148/cb424953668;776;"Fairy Tail"
# not OK
$ catmandu convert MARC to CSV --fix test.fix --sep_char "\t" < LF-1000.mrc > out.csv; more -3 out.csv
ark\id\title
http://catalogue.bnf.fr/ark:/12148/cb38873787v\775\Sangohan
http://catalogue.bnf.fr/ark:/12148/cb424953668\776\"Fairy Tail"

I tried differentsthings. Is it possible ?

Regards.

phochste commented 5 years ago

I see that the "\t" is not expanded in this module.

What you can do is instead of \t: press + and press . This provides a literal tab on the command line. Or, use the TSV exporter instead of CSV which provides tabs by default as sep_char.

clrh commented 5 years ago

Oh, ok TSV works very well :)

Thanks you @phochste

nics commented 5 years ago

The CSV exporter will also handle this correctly in the next release of Catmandu (commits e22fd90cc5e95d1061be4c870e597b207d3259f3 and bc4317855721bdccc65eb10a777278500065c79c)