python中对csv文件一列的求和
importcsvwithopen("C:\\Users\\hsc\\Desktop\\04-2012to04-201301.csv","r",encoding="utf...
import csv
with open("C:\\Users\\hsc\\Desktop\\04-2012 to 04-2013 01.csv", "r", encoding="utf-8") as f:
reader = csv.DictReader(f)
total=0
for row in reader:
if row['lon'] >= str(-40) and row['lon'] <=str(-80) and row['lat']>=str(0) and row['lat']<=str(60):
total = str(total) +'count(lon)'
print('total=',total)
不知道为什么就是求不出count(lon)这一列的和,求大神帮忙 展开
with open("C:\\Users\\hsc\\Desktop\\04-2012 to 04-2013 01.csv", "r", encoding="utf-8") as f:
reader = csv.DictReader(f)
total=0
for row in reader:
if row['lon'] >= str(-40) and row['lon'] <=str(-80) and row['lat']>=str(0) and row['lat']<=str(60):
total = str(total) +'count(lon)'
print('total=',total)
不知道为什么就是求不出count(lon)这一列的和,求大神帮忙 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询