我有一些 csv 格式的数据,我需要将第 3 列乘以第 6 列并将结果附加到末尾。我的数据如下:
TITLE,TITLE,T,T,T,T
data,data,5,data,data,98.7,data
data,data,2,data,data,97,data
data,data,5,data,data,98,data
data,data,4,data,data,8.7,data
data,data,5,data,data,9.7,data
data,data,12.5,data,data,198.7,data
我对编码真的很陌生,但我的尝试如下: import csv import datetime import copy from collections import defaultdict
class_col = 2
data_col = 5
with open('minitest.csv', 'r') as f:
data = [line.strip().split(',') for line in f]
for row in data:
class_col*data_col
with open('minitest_edit.csv', 'w') as nf:
nf.write('\n'.join(','.join(row) for row in data))
print "done"
我没有收到任何错误,有什么建议吗?感谢操作系统”