tabula error 'list' object has no attribute 'to_excel'


I tried to convert PDF file that contains the data table to excel file.
Here is my cord.

import tabula
# Read PDF File
df = tabula.read_pdf("files/Seniority List 2018 19.pdf", pages = 1)
# Convert into Excel File

but error occurred.

AttributeError                            Traceback (most recent call last)
Input In [5], in <cell line: 9>()
      6 df = tabula.read_pdf("files/Seniority List 2018 19.pdf", pages = 1)
      8 # # Convert into Excel File
----> 9 df.to_excel('files/excel.xlsx')

AttributeError: 'list' object has no attribute 'to_excel'

PDF is from here

How can I use ‘to_excel’??

I just mentioned the above settings in this question but still if more code is required then tell me I’ll update my question with that information. Thank you

Asked By: daylyroppo3




tabula returns a list of possible table

Answered By: batelme

instead of using df = tabula.read_pdf('file.pdf', pages = '1')

Use df = tabula.read_pdf('file.pdf', pages = '1')[0]

Answered By: Aakash Dawani
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.