Trouble with extracting tables with slightly misaligned vertical columns without rule lines using "text" strategy #1344
eugene8080
started this conversation in
Ask for help with specific PDFs
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm trying to extract the table from this pdf with pdfplumber
2025-Q2-FS_06302025_CF_Redacted.pdf
On the right most column, there are some ")" that occationally extend past the alignment of the rest of the numbers. I think the misalignment causes the ")" to be cut from the column. Similarly, there is a number "(20,191,164)" which is slightly longer than the rest and it also gets split. I have been playing around with the parameters but unable to grab the entire number. I understand i might be able to use "explicit" strategy instead, but I am doing a batch of files and the tables might not align so I want to stick with "text" strategy.


Here is the debug_tablefinder output:
Here is a table output which highlights the problematic cells:
Here is my code:
import pdfplumber
import pandas as pd
from IPython.display import display
pdf_path = r"../data/downloads/financial_reports/2025-Q2-FS_06302025_CF_Redacted.pdf"
with pdfplumber.open(pdf_path) as pdf:
page = pdf.pages[0]
settings = {
"vertical_strategy": "text",
"horizontal_strategy": "text",
"snap_tolerance": 3,
"snap_x_tolerance": 3,
"snap_y_tolerance": 3,
"join_tolerance": 3,
"join_x_tolerance": 3,
"join_y_tolerance": 3,
"edge_min_length": 3,
"min_words_vertical": 10,
"min_words_horizontal": 1,
"intersection_tolerance": 3,
"intersection_x_tolerance": 3,
"intersection_y_tolerance": 3,
"text_tolerance": 3,
"text_x_tolerance": 3,
"text_y_tolerance": 1,
}
tables = page.extract_tables(table_settings=settings)
if tables:
df = pd.DataFrame(tables[0][1:], columns=tables[0][0])
text = page.extract_text()
print(text)
print(df)
display(page.to_image(resolution=150).debug_tablefinder(table_settings=settings))
Beta Was this translation helpful? Give feedback.
All reactions