Python Forum

Full Version: Index out of range error
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am trying to simply load a pdf doc and use langchain to process so I could query it with ChatGPT. I cannot get past loading the pdf doc. Cannot figure out what I am doing wrong here. Tried this code hoping and expecting to get the text on the first page just to see if it is loading, but I get "index out of range" erro.

import langchain
import pypdf
from langchain.document_loaders import PyPDFLoader

PDFLoader= PyPDFLoader("RegexSplitTest.pdf")
pages = PDFLoader.load_and_split()
pages[0] 
Error:
IndexError Traceback (most recent call last) Cell In[34], line 7 5 PDFLoader= PyPDFLoader("RegexSplitTest.pdf") 6 pages = PDFLoader.load_and_split() ----> 7 pages[0] IndexError: list index out of range