Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • C csvkit
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 61
    • Issues 61
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 4
    • Merge requests 4
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • wireservice
  • csvkit
  • Issues
  • #906
Closed
Open
Issue created Nov 11, 2017 by Administrator@rootContributor

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!

Assignee
Assign to
Time tracking