Skip to content

Commit 941b7d5

Browse files
committed
Changed line definition in sr_ctsl PDF parsing to be statically defined
This is due to complications with MyPy being incompatible with dynamic parsing of the table's lines.
1 parent 83e428d commit 941b7d5

File tree

1 file changed

+1
-20
lines changed

1 file changed

+1
-20
lines changed

MISOReports/MISOReports.py

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2617,25 +2617,6 @@ def parse_cpnode_reszone(
26172617
def parse_sr_ctsl(
26182618
res: requests.Response,
26192619
) -> pd.DataFrame:
2620-
def get_vertical_lines_from_header(page: pdfplumber.page.Page, column_count: int = 13) -> list[int | float]:
2621-
# Adapted from: https://github.com/jsvine/pdfplumber/discussions/972#discussioncomment-6998179
2622-
table = page.find_table(table_settings={
2623-
"vertical_strategy": "lines",
2624-
"horizontal_strategy": "lines",
2625-
})
2626-
2627-
if not table:
2628-
return []
2629-
2630-
for row in table.rows:
2631-
if any(cell is None for cell in row.cells) or len(row.cells) != column_count:
2632-
continue
2633-
2634-
return [cell[0] for cell in row.cells] + [row.cells[-1][2]]
2635-
2636-
return []
2637-
2638-
26392620
with pdfplumber.open(io.BytesIO(res.content)) as pdf:
26402621
pg = pdf.pages[0]
26412622

@@ -2646,7 +2627,7 @@ def get_vertical_lines_from_header(page: pdfplumber.page.Page, column_count: int
26462627
"vertical_strategy": "explicit",
26472628
"horizontal_strategy": "text",
26482629
"snap_tolerance": 4,
2649-
"explicit_vertical_lines": get_vertical_lines_from_header(pg),
2630+
"explicit_vertical_lines": [18.9, 299.71666666666664, 355.80000000000007, 411.80000000000007, 467.80000000000007, 523.8000000000001, 579.8000000000001, 635.8000000000001, 691.8000000000001, 747.8000000000001, 803.8000000000001, 859.8000000000001, 915.8000000000001, 973.7833333333333],
26502631
"intersection_x_tolerance": 10,
26512632
})
26522633

0 commit comments

Comments
 (0)