kindly / flatterer

Opinionated JSON to CSV/XLSX/SQLITE/PARQUET converter. Flattens JSON fast.
https://flatterer.opendata.coop
MIT License
180 stars 7 forks source link

Error if the input file name is a number #29

Closed aborruso closed 2 years ago

aborruso commented 2 years ago

First of all, thank you for this really interesting project.

If my input file name is a number, after I run

flatterer --force  5709570636.json ./tmp

I have this error

Traceback (most recent call last):
  File "/home/aborruso/.local/bin/flatterer", line 8, in <module>
    sys.exit(cli())
  File "/home/aborruso/.local/lib/python3.9/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/home/aborruso/.local/lib/python3.9/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/home/aborruso/.local/lib/python3.9/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/aborruso/.local/lib/python3.9/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/home/aborruso/.local/lib/python3.9/site-packages/flatterer/__init__.py", line 214, in cli
    flatten(input_file,
  File "/home/aborruso/.local/lib/python3.9/site-packages/flatterer/__init__.py", line 130, in flatten
    csv_path = os.path.join(output_dir, 'csv', table + '.csv')
TypeError: unsupported operand type(s) for +: 'int' and 'str'

If I rename it in tmp_5709570636.json I have no error.

kindly commented 2 years ago

@aborruso thanks for the bug report.

This is now fixed in the latest version on pypi.

https://github.com/kindly/flatterer/commit/56cb6f04cb5dc9c38449a5ce3f25100bf50fbc73

aborruso commented 2 years ago

Thank you very much