Python Requests Giving Errror: Indexerror: List Index Out Of Range
Python requests giving error: IndexError: list index out of range : import os import csv import requests write_path = '/Users/specter/Desktop/pdfs/u' # ASSUMING THAT FOLDER EXIST
Solution 1:
There are probably some empty lines in your csv file. In that case link
will be the empty string ''
and you will get an index error. Change the code to:
.
.
.
with open('final.csv', 'r') as csvfile:
spamreader = csv.reader(csvfile)
forlink in spamreader:
ifnotlink:
continueprint('-'*72)
pdf_file = link[0].split('/')[-1]
.
.
.
On a further note; your code seems to be strangely indented. As it stands, it will only open the last pdf in final.csv
. Are you sure you do not want to indent your second with
statement, together with the rest of the code, one more level, to be executed within the for
loop?
Post a Comment for "Python Requests Giving Errror: Indexerror: List Index Out Of Range"