These seems like something very simple, but search as I might I just can't get past it.
I have a CSV file like this:
Day,Event,Value
1,"Rent",500
7,"Wage Payments",1000
I wish to add up all of the numbers in the 'value' column. So far, my code is this:
cr = csv.reader(open("file.csv","rb"))
for row in cr:
print row
#print sum(Value)
How could I go about summing that value?
Thank you.
sum(int(row[2]) for row in csv.reader(open("file.csv","rb")) if row[2].isdigit())sum(map(int, zip(*csv.reader(open("file.csv","rb")))[2][1:]))sum(int(row['Value']) for row in csv.DictReader(open("file.csv","rb")))