这是我当前的代码
a_reader = None
a_reader = open('data.csv', 'rU')
a_csv_reader = csv.reader(a_reader)
for row in a_csv_reader:
print row
a_reader.close()
count = 0
sum = 0.0
a_reader = open('data.csv', 'rU')
a_csv_reader = csv.reader(a_reader)
a_csv_reader.next()
for row in a_csv_reader:
if count != 0 and row[0] != '':
sum = sum + float(row[0])
count = count + 1
a_reader.close()
print 'Number of lines is:',count
print 'Sum is:',sum
return listStation
这会产生以下结果
['1', '476050', '7709929']
['2', '473971', '7707713']
['3', '465676', '7691097']
['4', '515612', '7702192']
['5', '516655', '7704405']
['6', '519788', '7713255']
['7', '538466', '7683341']
Number of lines is: 8
Sum is: 28.0
好的,现在我要做的是拆分 ID、Easting 和 Northing 的值并将它们附加到列表中以创建一个 2d 列表。是否有可能做到这一点?如果是这样,你能提供我的代码吗?