Is there any way to have a interval to set explict_vertical_lines #495
Replies: 3 comments 3 replies
-
Hi @youpengbo2018 Appreciate your interest in the library. Could you please provide more information? The PDF that is causing the issue and the pages where the variation is. Is it only the last line that is changing positions? If so, you can keep the last multiplier of the |
Beta Was this translation helpful? Give feedback.
-
市月度数据(202105).pdf |
Beta Was this translation helpful? Give feedback.
-
Thanks for sharing the PDF @youpengbo2018 Using the following table settings seems to work on both the PDFs. {
"vertical_strategy": "lines",
"horizontal_strategy": "lines",
"explicit_vertical_lines": [Decimal(page.width) * Decimal('0.04'), Decimal(page.width) * Decimal('0.94')],
"intersection_x_tolerance": 30,
} |
Beta Was this translation helpful? Give feedback.
-
This is the code that I have used to convert the pdf which doesn't have vertical edge. It works, but I want to loop a file, which has many similar pdf to convert.They have different width. Because of this, I have to change the explict_vertical_lines from 0.9 to 0.88 some time. I want to ask is there any idea that let the pdfplumber to have a interval about the explict vertical lines. So I can loop all the files and get the right content.
with pdfplumber.open(file_path) as pdf:
for i in range(pdf.pages[-1].page_number):
page = pdf.pages[i]
for table in page.extract_tables(table_settings={"vertical_strategy": "lines"
,"explicit_vertical_lines":[Decimal(page.width)*Decimal(0.07),Decimal(page.width)*Decimal(0.86),Decimal(page.width)*Decimal(0.9)]
,"horizontal_strategy": "lines",
}):
Beta Was this translation helpful? Give feedback.
All reactions