How To Convert Pdf File To Excel File Using Python
I want to convert a pdf file into excel and save it in local via python. I have converted the pdf to excel format but how should I save it local? my code: df = ('./Downloads/folder
Solution 1:
You can specify your whole output path instead of only output.csv
df = ("./Downloads/folder/myfile.pdf")
output = "./Downloads/folder/test.csv"
tabula.convert_into(df, output, output_format="csv", stream=True)
Hope this answers your question!!!
Solution 2:
In my case, the script below worked:
import tabula
df = tabula.read_pdf(r'C:\Users\user\Downloads\folder\3.pdf', pages='all')
tabula.convert_into(r'C:\Users\user\Downloads\folder\3.pdf', r'C:\Users\user\Downloads\folder\test.csv' , output_format="csv",pages='all', stream=True)
Solution 3:
PDF to .xlsx file:
for item in df:
list1.append(item)
df = pd.DataFrame(list1)
df.to_excel('outputfile.xlsx', sheet_name='Sheet1', index=True)
Solution 4:
Documentation says that:
Output file will be saved into output_path
output_path is your second parameter, "test.csv". I guess it works fine, but you are loking it in the wrong folder. It will be located near to your script (to be strict - in current working directory) since you didn't specify full path.
Solution 5:
The code that worked for me it was the below, but it isn´t reading all the pdf pages, just a few in the middle. What I´m doing wrong?
import tabula
df = tabula.read_pdf(r'C:\Users\user\Downloads\folder\3.pdf', pages='all')
tabula.convert_into(r'C:\Users\user\Downloads\folder\3.pdf', r'C:\Users\user\Downloads\folder\test.csv' , output_format="csv",pages='all', stream=True)
Post a Comment for "How To Convert Pdf File To Excel File Using Python"