camelot
camelot copied to clipboard
IndexError: list index out of range
I am trying to read a folder of pdfs and extracting data from the pdfs
Code is as follows:
for root, dirs, files in os.walk(".", topdown=False):
for file in files:
filename, extension = os.path.splitext(file)
if extension == '.pdf':
print(os.path.join(root, file))
tables = camelot.read_pdf(File)
df=tables[0].df # get a pandas
df.columns=(df.iloc[0])
df.drop(index=0, axis=0,inplace=True)
print(df.describe().T)
I get an error after reading first file:
IndexError Traceback (most recent call last)
C:\ProgramData\Anaconda3\lib\site-packages\camelot\core.py in getitem(self, idx) 672 673 def getitem(self, idx): --> 674 return self._tables[idx] 675 676 @staticmethod
IndexError: list index out of range
This means that the table wasn't read
This means that the table wasn't read Thanks, The first pdf loads properly but the error occurs when I try to read the second pdf. Do I need to reinitialize the camelot object?
@smathai02 , did the issue resolve for you ? i am facing similar issue ? could you please help me ?