Aman Punetha
Aman Punetha

Reputation: 25

'NoneType' object has no attribute 'to_csv'

error:'NoneType' object has no attribute 'to_csv'

code:

import tabula
df = tabula.read_pdf(r"C:\Users\admin\Desktop\Project_1\img1.pdf", encoding='utf-8')
df.to_csv(r"C:\Users\admin\Desktop\Project_1\otuput.csv", index=False)

Upvotes: 1

Views: 8764

Answers (1)

byTreneib
byTreneib

Reputation: 176

Try to print out the dataframe you read from the pdf file. This way you will notice if there was anything read from the file. To help you further there would be more information needed. For example show us the file you want to read, as there could be an error reading out it's content. Edit: There is another function provided by the tabula lib as well:

tabula.convert_into("input.pdf", "output.csv", output_format="csv")

this way you can directly put your dataframe into a csv file.

Upvotes: 1

Related Questions