Fix columns with falsy cells wrongly parsed as dates (#276)

Eg. before this commit, this table would result in Date columns:

| A     | B |
| ----- | -- |
| FALSE | 0 |

For now, even FALSE is parsed as Numeric (not sure why we don't have
a BooleanConverter).
pull/279/head
Yohan Boniface 2 years ago committed by GitHub
parent c9a81ea7ea
commit 8bc5c7d595
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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()

@ -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()

Loading…
Cancel
Save