Support for tab delimiter
mdraw opened this issue · 2 comments
mdraw commented
Is there a way to specify the tab character as the delimiter in the CLI?
If I run
$ csvtotable <tabseperatedcsv.csv> /tmp/out.html -d '\t'
the following error occurs:
Traceback (most recent call last):
File "/usr/bin/csvtotable", line 11, in <module>
load_entry_point('csvtotable==1.1.0', 'console_scripts', 'csvtotable')()
File "/usr/lib/python2.7/site-packages/click/core.py", line 722, in __call__
return self.main(*args, **kwargs)
File "/usr/lib/python2.7/site-packages/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/usr/lib/python2.7/site-packages/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/lib/python2.7/site-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/usr/lib/python2.7/site-packages/csvtotable/cli.py", line 30, in cli
delimiter=delimiter, quotechar=quotechar)
File "/usr/lib/python2.7/site-packages/csvtotable/convert.py", line 49, in convert
delimiter=delimiter, quotechar=quotechar)
File "/usr/lib/python2.7/site-packages/unicodecsv/py2.py", line 110, in __init__
self.reader = csv.reader(f, dialect, **kwds)
TypeError: "delimiter" must be an 1-character string
This also happens with Python 3.6.1.
shaunpud commented
Try running it with;
csvtotable <tabseperatedcsv.csv> /tmp/out.html -d $'\t'
mdraw commented
Thanks @shaunpud, this works in bash and zsh.
In fish (which is my main shell) the dollar sign doesn't work that way, but I found out that you just have to write it without quotes to make fish understand it(→ fish-shell/fish-shell#1338):
csvtotable <tabseperatedcsv.csv> /tmp/out.html -d \t
I see now that this is an issue with shells, not with csvtotable, so I will close this.