Answers for "how to sum a column in csv python using list in python"

0

how to sum a column in csv python using list in python

import csv
csv_file = csv.reader(open("your_file_name.csv"))

dist = 0
for row in csv_file:
    _dist = row[2]
    try: 
        _dist = float(_dist)
    except ValueError:
        _dist = 0

    dist += _dist
Posted by: Guest on November-30-2020

Code answers related to "how to sum a column in csv python using list in python"

Python Answers by Framework

Browse Popular Code Answers by Language