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.
Activity