|
|
|
@ -16,6 +16,8 @@ EXPECTED_TABLE_HEADERS = [
@@ -16,6 +16,8 @@ EXPECTED_TABLE_HEADERS = [
|
|
|
|
|
"Rest", |
|
|
|
|
] |
|
|
|
|
|
|
|
|
|
EXCEL_LINES_TO_IGNORE = {"stand:", "stand"} |
|
|
|
|
|
|
|
|
|
NUM_EXPECTED_HEADERS = len(EXPECTED_TABLE_HEADERS) |
|
|
|
|
|
|
|
|
|
ExcelRow = namedtuple("ExcelRow", ["row", "data"]) |
|
|
|
@ -47,16 +49,20 @@ def _check_table_header(xl_row):
@@ -47,16 +49,20 @@ def _check_table_header(xl_row):
|
|
|
|
|
raise BudgetParserError(msg) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _skip_empty_lines(rows): |
|
|
|
|
def _skip_some_lines(rows): |
|
|
|
|
for xl_row in rows: |
|
|
|
|
first_cell = xl_row.data[0] |
|
|
|
|
if is_empty_excel_value(first_cell): |
|
|
|
|
continue |
|
|
|
|
if isinstance(first_cell, str): |
|
|
|
|
value = first_cell.strip().lower() |
|
|
|
|
if value in EXCEL_LINES_TO_IGNORE: |
|
|
|
|
continue |
|
|
|
|
yield xl_row |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _parse_data_table(rows): |
|
|
|
|
for xl_row in _skip_empty_lines(rows): |
|
|
|
|
for xl_row in _skip_some_lines(rows): |
|
|
|
|
data = [ |
|
|
|
|
strip_excel_value(value) |
|
|
|
|
for value in xl_row.data[:NUM_EXPECTED_HEADERS] |
|
|
|
|