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

Excel sheets name issue #24

Closed yolile closed 2 years ago

yolile commented 2 years ago

There seems to be an issue with sheets names that have exactly 32 characters as the final sheet name. For example:

{
  "releases": [
    {
      "tender": {
        "items": [
          {
            "attributes": [
              {
                "id": "1"
              }
            ]
          }
        ]
      }
    }
  ]
}

(sheet name releases_tender_items_attributes)

Fails with:

thread '<unnamed>' panicked at 'byte index 6 is out of bounds of `items`', /root/.cargo/registry/src/github.com-1ecc6299db9ec823/libflatterer-0.12.1/src/lib.rs:1666:24
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Traceback (most recent call last):
  File "/usr/local/bin/flatterer", line 8, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/flatterer/__init__.py", line 164, in cli
    log_error=True)
  File "/usr/local/lib/python3.7/dist-packages/flatterer/__init__.py", line 56, in flatten
    inline_one_to_one, schema, table_prefix, path_separator, schema_titles, sqlite_path, log_error)
pyo3_runtime.PanicException: byte index 6 is out of bounds of `items`

But it works well with releases_tender_items_attribute and with releases_tender_items_attributess, for example. Note that releasess_tender_items_attribute and releases_tenders_items_attribute also fail but releases_tender_itemss_attribute don't.

Maybe related with #12

kindly commented 2 years ago

@yolile thanks for the report. This is now fixed in the latest release on pypi.

yolile commented 2 years ago

Awesome, thank you!