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! error type as None #321

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
9 changes: 9 additions & 0 deletions python/tests/test_fastexcel.py
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,15 @@ def test_null_values_in_cells() -> None:
pd_assert_frame_equal(sheet.to_pandas(), pd_expected)


def test_invalid_value_num() -> None:
excel_reader = fastexcel.read_excel(path_for_fixture("fixture-invalid-cell-value-num.xlsx"))
sheet = excel_reader.load_sheet(0)

expected = {"Column": [8, None]}
sphuber marked this conversation as resolved.
Show resolved Hide resolved
pd_assert_frame_equal(sheet.to_pandas(), pd.DataFrame(expected))
pl_assert_frame_equal(sheet.to_polars(), pl.DataFrame(expected))


def test_null_column_is_nullable() -> None:
sheet = fastexcel.read_excel(path_for_fixture("null-column.xlsx")).load_sheet(0)
assert sheet.to_arrow().schema.field("nullonly").nullable is True
Expand Down
2 changes: 1 addition & 1 deletion src/types/dtype.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ fn get_cell_dtype<DT: CellType + Debug + DataType>(
match cell.get_error() {
// considering cells with #N/A! or #REF! as null
Some(
CellErrorType::NA | CellErrorType::Value | CellErrorType::Null | CellErrorType::Ref,
CellErrorType::NA | CellErrorType::Value | CellErrorType::Null | CellErrorType::Ref | CellErrorType::Num,
) => Ok(DType::Null),
Some(err) => Err(FastExcelErrorKind::CalamineCellError(err.to_owned()).into()),
None => Err(FastExcelErrorKind::Internal(format!(
Expand Down
Loading