1
我是python的新手。因此,我非常感謝有關處理CSV文件中數據的問題。 (1)在我的代碼中,如何指定Data1和Data2插入到CSV文件的第9列和第10列中? (2)另外,爲了將來的參考,如何指定行和列來提取數據或寫入csv文件?指定列在python中輸入csv文件中的數據
file1 = open (fileA.csv, 'rb')
reader1 = csv.reader(file1)
outfile = open ('fileB.csv', 'wb')
writer = csv.writer(outfile)
next(reader1, None) # skip the headers
for col in reader1:
subset1 = [float(x) for x in col[3:6]]
Max1 = max (subset1)
Min1 = min (subset1)
Data1 = str(Max1 - Min1)
subset2 = [float(x) for x in col[6:9]]
Max2 = max (subset2)
Min2 = min (subset2)
Data2 = str(Max2 - Min2)
........????
writer.writerow(Data)
file1.close()
outfile.close()
非常感謝!