Skip to content

Commit 393e1c1

Browse files
committed
Merge pull request #95 from OpenDataServices/94-zero-not-converted
[#94] Convert zeros
2 parents 85b9c13 + c94b58e commit 393e1c1

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

flattentool/input.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ def list_as_dicts_to_temporary_dicts(unflattened):
303303
def unflatten_main_with_parser(parser, line, timezone):
304304
unflattened = {}
305305
for path, value in line.items():
306-
if not value:
306+
if value is None or value == '':
307307
continue
308308
current_path = unflattened
309309
path_list = [item.rstrip('[]') for item in path.split('/')]
@@ -349,7 +349,7 @@ def unflatten_main_with_parser(parser, line, timezone):
349349

350350
## Other Types
351351
converted_value = convert_type(current_type or '', value, timezone)
352-
if converted_value:
352+
if converted_value is not None and converted_value != '':
353353
current_path[path_item] = converted_value
354354

355355
unflattened = list_as_dicts_to_temporary_dicts(unflattened)

flattentool/tests/test_input_SpreadsheetInput_unflatten.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,19 @@ def inject_root_id(root_id, d):
5454
'testA': 3
5555
}]
5656
),
57+
# Basic with zero
58+
(
59+
[{
60+
'ROOT_ID': '1',
61+
'id': 2,
62+
'testA': 0
63+
}],
64+
[{
65+
'ROOT_ID': '1',
66+
'id': 2,
67+
'testA': 0
68+
}]
69+
),
5770
# Nested
5871
(
5972
[{

0 commit comments

Comments
 (0)