masaccio / numbers-parser

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

TypeError: unsupported type for timedelta seconds component: NoneType #68

Closed btrevizan closed 7 months ago

btrevizan commented 7 months ago

The error happens when I try to parse the rows of a table.

doc = Document("Balanços Mensais.numbers")
rows = doc.sheets()[0].tables()[0].rows()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/btrevizan/anaconda3/lib/python3.7/site-packages/numbers_parser/document.py", line 75, in rows
    [self.cell(row_num, col_num) for col_num in range(self.num_cols)]
  File "/Users/btrevizan/anaconda3/lib/python3.7/site-packages/numbers_parser/document.py", line 75, in <listcomp>
    [self.cell(row_num, col_num) for col_num in range(self.num_cols)]
  File "/Users/btrevizan/anaconda3/lib/python3.7/site-packages/numbers_parser/document.py", line 109, in cell
    return Cell.factory(self._model, self._table_id, row_num, col_num)
  File "/Users/btrevizan/anaconda3/lib/python3.7/site-packages/numbers_parser/cell.py", line 13, in factory
    cell_value = model.table_cell_decode(table_id, row_num, col_num)
  File "/Users/btrevizan/anaconda3/lib/python3.7/site-packages/numbers_parser/model.py", line 391, in table_cell_decode
    seconds=cell_value.date
TypeError: unsupported type for timedelta seconds component: NoneType

I would expect to get a corresponding pendulum.datetime object on Python for the specific column values.

Here the spreadsheet giving me the error: Balanços Mensais.zip

cat-numbers version = 2.3.13

Also, the number fields are coming as None when I convert all date fields to Text.

masaccio commented 7 months ago

More recent versions of the package have suitable checks to not cause the exception. However, the most recent packages do need python >= 3.8. Do you have any upgrade options?

btrevizan commented 7 months ago

I was running with Python 3.7. When I changed to 3.9, it worked. Thank you!