List index out of list Python CSV files
Question:
so im learning some python but i got a list out of index error at this point if i put my header index to 0 it works not the way i see it works but ok, but if i get an upper index for header it wont can you help me out why?photo of my csv file
[heres the first picture of my code]and 2nd pic3
Answers:
When you put your header index as 0
what is output?
Assuming your delimiter is tab
with open("sample.csv", "r") as csvfile:
reader = csv.reader(csvfile,delimiter='t')
headers = next(reader, None)
print(headers[1])
My delimeter was t after i changed it to it problem all solved
so im learning some python but i got a list out of index error at this point if i put my header index to 0 it works not the way i see it works but ok, but if i get an upper index for header it wont can you help me out why?photo of my csv file
[heres the first picture of my code]and 2nd pic3
When you put your header index as 0
what is output?
Assuming your delimiter is tab
with open("sample.csv", "r") as csvfile:
reader = csv.reader(csvfile,delimiter='t')
headers = next(reader, None)
print(headers[1])
My delimeter was t after i changed it to it problem all solved