Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- values_list = []
- for row in b:
- values_list.append(row[1])
- 1,2,3,4,5
- 1,2,3,4,5
- 1,2,3,4,5
- 1,2,3,4,5
- 0,1,2,3,4
- 2,3,4,5,6
- #!/bin/env python
- col = 2
- values = []
- with open('csv.csv', 'r') as csv:
- for line in csv.readlines():
- elements = line.strip().split(',')
- values.append(int(elements[col]))
- csum = sum(values)
- cavg = sum(values)/len(values)
- print("Sum of column %d: %f" % (col, csum))
- print("Avg of column %d: %f" % (col, cavg))
- $ python parsecsv.py
- Sum of column 0: 6.000000
- Avg of column 0: 1.000000
- $ python parsecsv.py
- Sum of column 2: 18.000000
- Avg of column 2: 3.000000
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement