I'm trying to get the average of part of a column in a csv file but I haven't been able to find the length. I noticed that when I run len it's counting the amount of characters and not the length from 2021-2003 (len should be 18).
*Note: This is for a class and will not be using pandas
import csv
with open('C:/Users/lblortz/Desktop/LakeMead.csv', newline='') as csv_file:
list_name = csv.reader(csv_file, delimiter=',')
index=0
total=0.0
count=0.0
for YEAR, AVGELEVATION, AVGCONTENT, AVGINFLOW, AVGOUTFLOW, AVGHIGHTEMP, AVGLOWTEMP, AVGWATERTEMP in list_name:
if index != 0:
if int(YEAR)>=2003:
print(len(list_name))
total= float(AVGELEVATION) + total
index+=1
count=total/len(list_name)
print("average is",count)