agate: csvjson: key Decimal('31001') is not a string
Created by: Jamim
Hi all,
It looks like there is an issue with csvjson
when the key column is a column of numbers.
When I'm trying to execute $ csvjson --indent 4 --key fips acs2012_5yr_population.csv | head
according to the tutorial I'm getting the following error message:
key Decimal('31001') is not a string
.
Verbose output:
$ csvjson -v --indent 4 --key fips acs2012_5yr_population.csv
{
Traceback (most recent call last):
File "/home/mim/venv/csvkit_3.6.3/bin/csvjson", line 11, in <module>
load_entry_point('csvkit==1.0.2', 'console_scripts', 'csvjson')()
File "/home/mim/venv/csvkit_3.6.3/lib64/python3.6/site-packages/csvkit/utilities/csvjson.py", line 196, in launch_new_instance
utility.run()
File "/home/mim/venv/csvkit_3.6.3/lib64/python3.6/site-packages/csvkit/cli.py", line 114, in run
self.main()
File "/home/mim/venv/csvkit_3.6.3/lib64/python3.6/site-packages/csvkit/utilities/csvjson.py", line 190, in main
indent=self.args.indent
File "/home/mim/venv/csvkit_3.6.3/lib64/python3.6/site-packages/agate/table/to_json.py", line 88, in to_json
dump_json(output)
File "/home/mim/venv/csvkit_3.6.3/lib64/python3.6/site-packages/agate/table/to_json.py", line 68, in dump_json
json.dump(data, f, **json_kwargs)
File "/usr/lib64/python3.6/json/__init__.py", line 179, in dump
for chunk in iterable:
File "/usr/lib64/python3.6/json/encoder.py", line 430, in _iterencode
yield from _iterencode_dict(o, _current_indent_level)
File "/usr/lib64/python3.6/json/encoder.py", line 376, in _iterencode_dict
raise TypeError("key " + repr(key) + " is not a string")
TypeError: key Decimal('31001') is not a string
Environment:
$ csvjson --version
csvjson 1.0.2
$ uname -a
Linux irma-sun 4.13.11-gentoo #1 SMP Sun Nov 5 01:13:00 +03 2017 x86_64 Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz GenuineIntel GNU/Linux
$ python --version
Python 3.6.3
$ pip freeze
agate==1.6.0
agate-dbf==0.2.0
agate-excel==0.2.1
agate-sql==0.5.2
Babel==2.5.1
csvkit==1.0.2
dbfread==2.0.7
et-xmlfile==1.0.1
future==0.16.0
isodate==0.6.0
jdcal==1.3
leather==0.3.3
openpyxl==2.4.9
parsedatetime==2.4
pjson==1.0
Pygments==2.2.0
python-slugify==1.2.4
pytimeparse==1.1.7
pytz==2017.3
six==1.11.0
SQLAlchemy==1.1.15
Unidecode==0.4.21
xlrd==1.1.0
xmlformatter==0.1.1
Best regards, and thanks a lot for the great tools!