Skip to content

Commit

Permalink
Merge pull request #621 from yanokwa/more-empty-rows
Browse files Browse the repository at this point in the history
More likely to be more empty rows than empty columns
  • Loading branch information
lindsay-stevens authored Nov 16, 2022
2 parents b9be566 + 46302b2 commit 2b150d3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pyxform/xls2json_backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ def trim_trailing_empty(a_list: list, n_empty: int) -> list:

def get_excel_column_headers(first_row: Iterator[Optional[str]]) -> List[Optional[str]]:
"""Get column headers from the first row; stop if there's a run of empty columns."""
max_adjacent_empty = 20
max_adjacent_empty_columns = 20
column_header_list = list()
adjacent_empty_cols = 0
for column_header in first_row:
if is_empty(column_header):
# Preserve column order (will filter later)
column_header_list.append(None)
# After a run of empty cols, assume we've reached the end of the data.
if max_adjacent_empty < adjacent_empty_cols:
if max_adjacent_empty_columns < adjacent_empty_cols:
break
adjacent_empty_cols += 1
else:
Expand All @@ -81,7 +81,7 @@ def get_excel_rows(
cell_func: Callable[[aCell, int, str], Any],
) -> List[Dict[str, Any]]:
"""Get rows of cleaned data; stop if there's a run of empty rows."""
max_adjacent_empty = 20
max_adjacent_empty_rows = 60
col_header_enum = list(enumerate(headers))
adjacent_empty_rows = 0
result_rows = []
Expand All @@ -99,7 +99,7 @@ def get_excel_rows(

if 0 == len(row_dict):
# After a run of empty rows, assume we've reached the end of the data.
if max_adjacent_empty < adjacent_empty_rows:
if max_adjacent_empty_rows < adjacent_empty_rows:
break
adjacent_empty_rows += 1
else:
Expand Down

0 comments on commit 2b150d3

Please sign in to comment.