Skip to content

Commit 02a9b8a

Browse files
sphuberlukapeschke
andauthored
fix: consider #NUM! error type as None (#321)
* consider `#NUM!` error type as `None` * Update python/tests/test_fastexcel.py Co-authored-by: Luka Peschke <mail@lukapeschke.com>
1 parent 9086487 commit 02a9b8a

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed
5.78 KB
Binary file not shown.

python/tests/test_fastexcel.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,15 @@ def test_null_values_in_cells() -> None:
533533
pd_assert_frame_equal(sheet.to_pandas(), pd_expected)
534534

535535

536+
def test_invalid_value_num() -> None:
537+
excel_reader = fastexcel.read_excel(path_for_fixture("fixture-invalid-cell-value-num.xlsx"))
538+
sheet = excel_reader.load_sheet(0)
539+
540+
expected = {"Column": [8.0, None]}
541+
pd_assert_frame_equal(sheet.to_pandas(), pd.DataFrame(expected))
542+
pl_assert_frame_equal(sheet.to_polars(), pl.DataFrame(expected))
543+
544+
536545
def test_null_column_is_nullable() -> None:
537546
sheet = fastexcel.read_excel(path_for_fixture("null-column.xlsx")).load_sheet(0)
538547
assert sheet.to_arrow().schema.field("nullonly").nullable is True

src/types/dtype.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ fn get_cell_dtype<DT: CellType + Debug + DataType>(
229229
match cell.get_error() {
230230
// considering cells with #N/A! or #REF! as null
231231
Some(
232-
CellErrorType::NA | CellErrorType::Value | CellErrorType::Null | CellErrorType::Ref,
232+
CellErrorType::NA | CellErrorType::Value | CellErrorType::Null | CellErrorType::Ref | CellErrorType::Num,
233233
) => Ok(DType::Null),
234234
Some(err) => Err(FastExcelErrorKind::CalamineCellError(err.to_owned()).into()),
235235
None => Err(FastExcelErrorKind::Internal(format!(

0 commit comments

Comments
 (0)