Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IndexError: list index out of range #96

Closed
vinayak-mehta opened this issue Dec 11, 2018 · 1 comment
Closed

IndexError: list index out of range #96

vinayak-mehta opened this issue Dec 11, 2018 · 1 comment

Comments

@vinayak-mehta
Copy link

vinayak-mehta commented Dec 11, 2018

I'm trying to extract tables from the following PDFs: [1] and [2] using the code in this gist. The code fails with the following traceback:

Traceback (most recent call last):
  File "plumb.py", line 10, in 
    table = p0.extract_table()
  File "/home/vinayak/.local/share/virtualenvs/camelot-pdfplumber/local/lib/python2.7/site-packages/pdfplumber/page.py", line 185, in extract_table
    largest = list(sorted(tables, key=sorter))[0]
IndexError: list index out of range

I'm on Python 2.7 and pdfplumber 0.5.11. Any pointers on how I can solve this?

@jsvine
Copy link
Owner

jsvine commented Apr 15, 2019

Hi @vinayak-mehta, and my apologies for the slowness in responding. It appears that pdfplumber's default table-extraction settings don't identify a table in the on the first page of that PDF, and so the list of tables is empty, triggering that IndexError. It's worth taking a look at the library's table-extraction options. In this case, it looks like you'd want to change vertical_strategy and horizontal_strategy.

@jsvine jsvine closed this as completed Apr 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants