diff --git a/sandbox/grist/imports/fixtures/test_falsy_cells.xlsx b/sandbox/grist/imports/fixtures/test_falsy_cells.xlsx new file mode 100644 index 00000000..d4efdf50 Binary files /dev/null and b/sandbox/grist/imports/fixtures/test_falsy_cells.xlsx differ diff --git a/sandbox/grist/imports/import_xls_test.py b/sandbox/grist/imports/import_xls_test.py index a905ef9a..935c7104 100644 --- a/sandbox/grist/imports/import_xls_test.py +++ b/sandbox/grist/imports/import_xls_test.py @@ -189,5 +189,22 @@ class TestImportXLS(unittest.TestCase): ], }]) + def test_falsy_cells(self): + # Falsy cells should be parsed as Numeric, not Date. + parsed_file = import_xls.parse_file(*_get_fixture('test_falsy_cells.xlsx')) + tables = parsed_file[1] + self.assertEqual(tables, [{ + 'table_name': 'Sheet1', + 'column_metadata': [ + {'id': u'A', 'type': 'Numeric'}, + {'id': u'B', 'type': 'Numeric'}, + ], + 'table_data': [ + [0, 0], + [0, 0], + ], + }]) + + if __name__ == '__main__': unittest.main() diff --git a/sandbox/grist/parse_data.py b/sandbox/grist/parse_data.py index 47f95d04..20ed9ea2 100644 --- a/sandbox/grist/parse_data.py +++ b/sandbox/grist/parse_data.py @@ -83,7 +83,7 @@ class SimpleDateTimeConverter(BaseConverter): def convert(cls, value): if type(value) is datetime.datetime: return value - elif not value: + elif value is None: return None raise ValueError()