I am trying to read a CSV file and insert into a PostgreSQL database. But I want 1st and 5th column item as integer. So, I am converting 1st and 5th columns into an integer. But it is showing error < date_2 = int(row[0])
IndexError: list index out of range>
with open('parts_time.txt') as csvfile:
readCSV = csv.reader(csvfile, delimiter=',')
for row in readCSV:
date_2 = int(row[0])
date_4 = int(row[4])
cursor.execute("INSERT INTO parts_time
(time_id,time_day,time_month,time_year,vendor_idk)"\
"VALUES (%s,%s,%s,%s,%s)",
[date_2,row[1],row[2],row[3],date_4])