I get this error reading CSV file (no headers, 3 columns, 2nd and 3rd strings):
Traceback (most recent call last):
File "C:\Python32\fantasy.py", line 72, in module>
some=row[1]
IndexError: list index out of range*
Here is part of the code below. It’s stupidly simple stuff to be stuck on, but I’m just blank about how it isn’t working. I’m new to coding, but have dealt with csv module before and never had problems with this part, and just made some test csv file in notepad to see if it will be read from the same code, and it does. I don’t know.
import csv
##############some other code, working good and I believe not relevant to this problem
file=open(r"C:\Users\me\Desktop\file-2.csv","r")
reader=csv.reader(file, delimiter=',', quotechar='"')
for row in reader:
some=row[1]
Try checking for blank lines. Also, avoid using
fileas a variable name."r"is the default mode with open.