Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider #NUM! errors values as None #320

Closed
sphuber opened this issue Jan 10, 2025 · 0 comments · Fixed by #321
Closed

Consider #NUM! errors values as None #320

sphuber opened this issue Jan 10, 2025 · 0 comments · Fixed by #321

Comments

@sphuber
Copy link
Contributor

sphuber commented Jan 10, 2025

Consider the following example file:
fixture-invalid-cell-value-num.xlsx
image
This currently fails with:

In [46]: r = fastexcel.read_excel("tmp/ex_broken_minimal.xlsx")

In [47]: r.load_sheet(0)
---------------------------------------------------------------------------
CalamineCellError                         Traceback (most recent call last)
Cell In[47], line 1
----> 1 r.load_sheet(0)

File /usr/local/lib/python3.9/site-packages/fastexcel/__init__.py:256, in ExcelReader.load_sheet(self, idx_or_name, header_row, column_names, skip_rows, n_rows, schema_sample_rows, dtype_coercion, use_columns, dtypes)
    205 def load_sheet(
    206     self,
    207     idx_or_name: int | str,
   (...)
    216     dtypes: DType | DTypeMap | None = None,
    217 ) -> ExcelSheet:
    218     """Loads a sheet lazily by index or name.
    219 
    220     :param idx_or_name: The index (starting at 0) or the name of the sheet to load.
   (...)
    253                    or dict of dtypes with keys as column indices or names.
    254     """
    255     return ExcelSheet(
--> 256         self._reader.load_sheet(
    257             idx_or_name=idx_or_name,
    258             header_row=header_row,
    259             column_names=column_names,
    260             skip_rows=skip_rows,
    261             n_rows=n_rows,
    262             schema_sample_rows=schema_sample_rows,
    263             dtype_coercion=dtype_coercion,
    264             use_columns=use_columns,
    265             dtypes=dtypes,
    266             eager=False,
    267         )
    268     )

CalamineCellError: calamine cell error: #NUM!
Context:
    0: could not determine dtype for column 8

The #NUM! value is parsed by calamine just fine, it just raises CellErrorType::Num

This was fixed for #N/A errors in #180 . We could add the same handling for CellErrorType::Num perhaps?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant