I'm looking for a way in which I could make calculation of one column and add it into the column below.
Example: I have this file as input:
Name;Size
Paul;175
Simon;178
Jhon;120
Result expected in the other csv file:
Total size = 473
Average = 157
Number of player called paul =1
This is what I have:
import operator
data = csv.reader(open('player.csv'),delimiter=';')
total=0
for row in data:
total += int(row[2])
with open("result.csv", "wb") as f:
writer = csv.writer(f)
writer.writerows(total)
But it seems that total cannot be written into the other csv file. The thing is I don't know how to print all the calculation into the csv.
Any help would be great, BR
csvmodule. It's pretty insightful.row[2]means the third column. The first column issize[0]and the second column isrow[1].