0

I am trying to elevate my basic python skills tinkering with some codes generated with the help of ChatGPT.

This is the code I have for converting PDF to Excel.

I keep getting the error that file is not found. it is obviously there. i copied the file path from the folder.

I am at a loss as to why this is not working. Read other Overflow answers here and none of them seemed to work for me.

thanks a lot in advance

import tabula
import pandas as pd


pdf_file = "C:\Users\EditedName\Desktop\Personal\Python\PDF conversion\DMR-6122023.pdf"


df = tabula.read_pdf(pdf_file, pages='all')


dfs = []
for i, page in enumerate(df):
    df_page = pd.DataFrame(page)
    dfs.append(df_page)


combined_df = pd.concat(dfs)


excel_file = "C:\Users\EditedName\Desktop\Personal\Python\PDF conversion\DMR-6122023.pdf.xlsx"
combined_df.to_excel(excel_file, index=False)

print("Conversion complete. Excel file saved.")

0 Answers0