kindly / flatterer

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

bug: str generator causes TypeError #26

Closed jpmckinney closed 2 years ago

jpmckinney commented 2 years ago
import flatterer

flatterer.flatten(["foo"], dataframe=True)
File lib/python3.8/site-packages/flatterer/__init__.py:52, in bytes_generator(iterator)
     51 if isinstance(item, str):
---> 52     yield str.encode()
     53 if isinstance(item, dict):

TypeError: descriptor 'encode' of 'str' object needs an argument

Should be at minimum item.encode() and probably item.encode("utf-8").

kindly commented 2 years ago

@jpmckinney agreed

Once changed there needs a test, and JSON string/bytes iterators added to the docs.

kindly commented 2 years ago

@jpmckinney this is now fixed, but keeping issue open as if the strings are not valid JSON then the errors are not very clear.

jpmckinney commented 2 years ago

Thank you!

jpmckinney commented 2 years ago

Fixed in 03fda226a4df478c325691c378faac096caf0dc2