Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -124,6 +124,8 @@ Primary goals for reconcile rate:
|
|
| 124 |
keep the table with richer description text so output matches the PDF once. (b) Common OCR
|
| 125 |
typos (e.g. CINTHIAL→CINTHIA L) and double-escaped ampersands (&→&).
|
| 126 |
Gap between tables must not contain another <table> or page-separator.
|
|
|
|
|
|
|
| 127 |
"""
|
| 128 |
|
| 129 |
# Patch asyncio first (before Gradio imports it) to suppress Python 3.13 cleanup noise
|
|
@@ -524,11 +526,33 @@ def _drop_truly_empty_columns(grid):
|
|
| 524 |
new_grid.append([cell for idx, cell in enumerate(row) if idx < len(keep) and keep[idx]])
|
| 525 |
return new_grid
|
| 526 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 527 |
def _merge_blank_header_text_columns(grid):
|
| 528 |
if not grid or len(grid) < 2:
|
| 529 |
return grid
|
| 530 |
|
| 531 |
header = [str(c or "").strip() for c in grid[0]]
|
|
|
|
|
|
|
|
|
|
| 532 |
ncols = len(header)
|
| 533 |
body = grid[1:]
|
| 534 |
blank_cols = [i for i, h in enumerate(header) if h == ""]
|
|
|
|
| 124 |
keep the table with richer description text so output matches the PDF once. (b) Common OCR
|
| 125 |
typos (e.g. CINTHIAL→CINTHIA L) and double-escaped ampersands (&amp;→&).
|
| 126 |
Gap between tables must not contain another <table> or page-separator.
|
| 127 |
+
- Fix MD-2: Skip blank-header column merge for YOUR CHECKS SEQUENCED–style tables (title + repeated
|
| 128 |
+
Amount columns + blank th between triplets); merge was collapsing multi-column check rows.
|
| 129 |
"""
|
| 130 |
|
| 131 |
# Patch asyncio first (before Gradio imports it) to suppress Python 3.13 cleanup noise
|
|
|
|
| 526 |
new_grid.append([cell for idx, cell in enumerate(row) if idx < len(keep) and keep[idx]])
|
| 527 |
return new_grid
|
| 528 |
|
| 529 |
+
|
| 530 |
+
def _is_multigroup_check_list_header(header: List[str]) -> bool:
|
| 531 |
+
"""
|
| 532 |
+
Wide check listings (e.g. YOUR CHECKS SEQUENCED) use one row with a title cell, repeated
|
| 533 |
+
Amount headers, and blank <th> slots between DATE | CHECK # | AMOUNT triplets. Fix 3
|
| 534 |
+
blank-header merge would otherwise fuse the next column into Amount or the section title,
|
| 535 |
+
leaving only the first date column visibly populated.
|
| 536 |
+
"""
|
| 537 |
+
if not header:
|
| 538 |
+
return False
|
| 539 |
+
joined = " ".join(str(c or "").strip() for c in header).upper()
|
| 540 |
+
if "SEQUENCED" in joined and "CHECK" in joined:
|
| 541 |
+
return True
|
| 542 |
+
# Repeated Amount columns in one header row = multi-group layout; do not merge blanks.
|
| 543 |
+
if sum(1 for c in header if str(c or "").strip().upper() == "AMOUNT") >= 2:
|
| 544 |
+
return True
|
| 545 |
+
return False
|
| 546 |
+
|
| 547 |
+
|
| 548 |
def _merge_blank_header_text_columns(grid):
|
| 549 |
if not grid or len(grid) < 2:
|
| 550 |
return grid
|
| 551 |
|
| 552 |
header = [str(c or "").strip() for c in grid[0]]
|
| 553 |
+
if _is_multigroup_check_list_header(header):
|
| 554 |
+
return grid
|
| 555 |
+
|
| 556 |
ncols = len(header)
|
| 557 |
body = grid[1:]
|
| 558 |
blank_cols = [i for i, h in enumerate(header) if h == ""]
|