-
Notifications
You must be signed in to change notification settings - Fork 1
/
get_data.py
43 lines (39 loc) · 1.45 KB
/
get_data.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
__author__ = 'Rene'
import os
from pandas import DataFrame
from pandas import ExcelWriter
path="C:\Users\Rene\Desktop\experientos\data-GRIEWANK-24WRANDOM\data-griewank24random2"
param=[]
for counter, filename in enumerate(os.listdir(path)):
w12_file = open("%s/%s" % (path,filename))
parametros = [line.split(",") for counter, line in enumerate(w12_file) if counter == 1]
param.append((parametros[0][12],parametros[0][13]))
tiempo=[]
total=[]
for counter, filename in enumerate(os.listdir(path)):
w12_file = open("%s/%s" % (path,filename))
w12_records = [line.split(",") for line in w12_file if len(line.split(",")) == 3]
l=[]
promedio=0
for x in w12_records:
promedio=promedio + float(x[1])
l.append((counter,x[1],param[counter]))
tiempo.append(x[1])
if len(l)==5:
promedio=promedio/5
print l,promedio
total.append(promedio)
tiempo.append(promedio)
del l
else:
pass
#writer = ExcelWriter(path)
# for n in len(total):
# n = DataFrame({'ok':df1[n]} for n,df1 in enumerate(total))
# for n, df1 in enumerate(total):
# df=DataFrame({'ok':df1[n]} for df1 in total)
# #df1.to_excel(writer, 'sheet1')
# writer.save()
#x=list[range(1,len(total))]
df=DataFrame({'X':x,'Y':y} for x, y in enumerate(total))
df.to_excel(("%s/%s" % (path,'promedio.xlsx')), sheet_name='sheet1', index=False)