[Python] Pulling data from table on each page of PDF, and appending all together into one...

Discussão em 'Python' iniciado por Stack, Maio 28, 2025.

  1. Stack

    Stack Membro Participativo

    I have a pdf with several pages, and I want to extract the data from every page and concatenate them all into one dataframe. I've managed to dig through Stack and other resources to create the below code, which successfully extracts and prints the tables as dataframes from every page. However, the next step would be to concatenate each of these individual dataframes row-wise (so that it's one dataframe instead of several separate dataframes).

    import pdfplumber
    import pandas as pd

    pdf_file = "df.pdf"
    tables=[]
    with pdfplumber.open(pdf_file) as pdf:
    pages = pdf.pages
    for i,pg in enumerate(pages):
    tbl = pages.extract_table()
    df = pd.DataFrame(tbl)
    print(f'{df}')


    I'm stuck trying to figure out how to concatenate each of the dataframes in this loop instead of just printing them out, and would love any help. Thanks!

    Continue reading...

Compartilhe esta Página