You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Distinguish empty-string cells from blank cells #260
to_python() and iter_rows() return '' for both a blank cell and a cell holding an empty string, so callers can't tell them apart. That matters when importing data where an empty string and a missing value mean different things (e.g. mapping blanks to NULL but keeping '').
importxlwtfrompython_calamineimportCalamineWorkbookbook=xlwt.Workbook()
sheet=book.add_sheet("s")
sheet.write(0, 0, xlwt.Formula('""')) # A1: formula whose result is an empty stringsheet.write(0, 1, "x")
sheet.write(1, 1, "x") # A2: no cell at allbook.save("t.xls")
print(CalamineWorkbook.from_path("t.xls").get_sheet_by_index(0).to_python())
# [['', 'x'], ['', 'x']]
Tested on 0.9.1. xlrd reports A1 as XL_CELL_TEXT and A2 as XL_CELL_EMPTY.
The calamine crate does keep the difference in its XLS reader (Data::String("") vs an absent cell, in 0.37.0). It seems to be lost in CellValue::Empty => "" in src/types/cell.rs.
Since changing the default would affect existing callers, could this be opt-in, for example a keyword on to_python() / iter_rows() that returns None for blank cells? This is close to #105 / #258 on error cells, which are also indistinguishable from blanks, so one typed-value approach might cover both.
I reproduced this with synthetic XLS and XLSX samples. With python-calamine 0.9.1, both to_python() and iter_rows() return '' for the XLS formula's empty-string result and an absent cell. A separate Rust probe using calamine 0.38.0 (the current master dependency) reads the same XLS and a synthetic XLSX as Data::String("") for the empty-string formula result and Data::Empty for the absent cell.
One detail matters for compatibility: the current Python conversion also maps error values to CellValue::Empty. Simply changing that variant to None would therefore change error results too, in addition to overlapping with #258.
Would you prefer an opt-in empty_as_none=False keyword on both to_python() and iter_rows(), which returns None only for underlying Data::Empty (including padding) while leaving existing defaults and error handling unchanged? Or should this wait for a broader typed-cell API alongside #258? I can prepare tests for the default and opt-in paths, including leading empty rows and both XLS and XLSX.
Thanks for reproducing it, and for catching the error mapping. I'd go with the opt-in empty_as_none now rather than waiting for a typed-cell API. It's additive, it doesn't block a typed API later, and leaving errors alone keeps it separate from #258.
None for padding is right for our use too, since an absent cell and a padded one both mean "no value". Today we re-read the workbook with xlrd/openpyxl just to find the empty-string cells, and this keyword would let us drop that pass.
Activity
rayw-lab commentedon Nov 22, 2026
I reproduced this with synthetic XLS and XLSX samples. With
python-calamine0.9.1, bothto_python()anditer_rows()return''for the XLS formula's empty-string result and an absent cell. A separate Rust probe usingcalamine0.38.0 (the current master dependency) reads the same XLS and a synthetic XLSX asData::String("")for the empty-string formula result andData::Emptyfor the absent cell.One detail matters for compatibility: the current Python conversion also maps error values to
CellValue::Empty. Simply changing that variant toNonewould therefore change error results too, in addition to overlapping with #258.Would you prefer an opt-in
empty_as_none=Falsekeyword on bothto_python()anditer_rows(), which returnsNoneonly for underlyingData::Empty(including padding) while leaving existing defaults and error handling unchanged? Or should this wait for a broader typed-cell API alongside #258? I can prepare tests for the default and opt-in paths, including leading empty rows and both XLS and XLSX.rad-pat commentedon Nov 23, 2026
Thanks for reproducing it, and for catching the error mapping. I'd go with the opt-in
empty_as_nonenow rather than waiting for a typed-cell API. It's additive, it doesn't block a typed API later, and leaving errors alone keeps it separate from #258.Nonefor padding is right for our use too, since an absent cell and a padded one both mean "no value". Today we re-read the workbook with xlrd/openpyxl just to find the empty-string cells, and this keyword would let us drop that pass.