masaccio / numbers-parser

Python module for parsing Apple Numbers .numbers files
MIT License
201 stars 14 forks source link

Key error 29 #80

Open rubinglen opened 3 months ago

rubinglen commented 3 months ago

Strange error I'm getting when I try to run numbers_parser on certain files, it yields a stack with key error 29, other Numbers files it seems to work fine on. Any advice?

Traceback (most recent call last): File "/Users/glucosamigos/py_scripts/ocr_goo.py", line 197, in numdoc = Document("/Users/glucosamigos/py_scripts/newsheet.numbers") File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/numbers_parser/document.py", line 90, in init self._sheets = ItemsList(self._model, refs, Sheet) File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/numbers_parser/containers.py", line 11, in init self._items = [itemclass(model, ) for _ in refs] File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/numbers_parser/document.py", line 324, in init self._tables = ItemsList(self._model, refs, Table) File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/numbers_parser/containers.py", line 11, in init self._items = [itemclass(model, ) for _ in refs] File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/numbers_parser/document.py", line 431, in init cell_storage = model.table_cell_decode(table_id, row, col) File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/numbers_parser/numbers_cache.py", line 25, in inner_multi_args value = func(self, *args, *kwargs) File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/numbers_parser/model.py", line 1760, in table_cell_decode return CellStorage(self, table_id, buffer, row, col) File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/numbers_parser/cell_storage.py", line 196, in init self.value = self.model.table_string(table_id, self.string_id) File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/numbers_parser/numbers_cache.py", line 25, in inner_multi_args value = func(self, args, **kwargs) File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/numbers_parser/model.py", line 491, in table_string return self._table_strings.lookup_value(table_id, key).string File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/numbers_parser/model.py", line 169, in lookup_value return self._datalists[table_id]["by_key"][key] KeyError: 29

masaccio commented 3 months ago

The line that refers to CellStorage suggests you have a slightly older version of numbers-parser (I changed this last week). The error itself is numbers-parser not finding a string in the string table. If the new version doesn’t work you would need to share a broken file with me.

The best approach to reduce confidential data to a test case is to progressively delete half the data and rechecking. If the file loads after deleting half, undo and delete the other half. I’ve found this bisecting technique gets me a minimal example pretty quickly.

darioclock commented 3 months ago

I get the same error when I try to open a corrupted file on issue #79

rubinglen commented 3 months ago

If it's corrupted than that's the fault of numbers_parser itself since it's a file that numbers_parser was working with and saving to. I will try to update numbers_parser and bisect the file next time at the office.

On Thu, Mar 21, 2024, 7:41 AM darioclock @.***> wrote:

I get the same error when I try to open a corrupted file on issue #79 https://github.com/masaccio/numbers-parser/issues/79

— Reply to this email directly, view it on GitHub https://github.com/masaccio/numbers-parser/issues/80#issuecomment-2012478252, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB5LTKT46FYDE2KHC53JWCTYZLWQJAVCNFSM6AAAAABFAN4JOKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMJSGQ3TQMRVGI . You are receiving this because you authored the thread.Message ID: @.***>

masaccio commented 3 months ago

v4.10.4 contains some fixes to datalists.