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