[Python] How extract exact match from tabular huge tabular pdfs

Discussão em 'Python' iniciado por Stack, Fevereiro 23, 2025.

  1. Stack

    Stack Membro Participativo

    I am using Python to read many PDFs, and they are quite large (some have 40 pages, others 3000). Therefore, I need some optimization. As such, these PDFs have tabulated data and everything is well-structured. From these tables, I need to match a record and extract a row from each PDF, but since there are so many, my kernel crashes...

    I was using Pdfplumber and also tried with LlamaReadMarkdown. Any suggestions? Here is my code

    with pdfplumber.open(pdf_path) as pdf:
    for page in pdf.pages[1:]:
    tables = page.extract_table()
    if tables:
    df = pd.DataFrame(tables[1:], columns=tables[0])
    for index, row in df.iterrows():
    if rut in row.values:
    return df.loc[[index]]
    return None


    Im thinking to process it by batch but it will be viable?

    Continue reading...

Compartilhe esta Página