A complete novice, I beg you all for help! !
import csv
with open('shiyan.csv', 'rb') as f:
reader = csv.reader(f)
your_list = list(reader)
data = map(list,zip(*your_list))
for i,data in enumerate(data):
row = data
row = map(eval, row)
listA=row
result=[float( sum(listA[i:i+10])/10) for i,num in enumerate(listA) if i%10==0]
print result
The running results are as follows. Now I want to write the results obtained from each loop into a new csv file in sequence, but it is best to write them column by column. Thank you very much! ! ! ! ! ! !
It is recommended that you put the data into the pandas dataframe and then call pandas.to_csv
I changed your code, and the actual measurement can be obtained from
a.csv
复制到b.csv
中If you don’t understand, you can ask again