答案 0 :(得分:2)
使用pandas
模块,它可能看起来像(或多或少)
import pandas as pd
df = pd.read_csv(filename, ... some other options ...)
print df[2].sum()
# print df['distance'].sum()
答案 1 :(得分:0)
这是使用内置csv模块的方法
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