-
Notifications
You must be signed in to change notification settings - Fork 0
/
averager.py
92 lines (81 loc) · 3.77 KB
/
averager.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/usr/bin/env python3
import csv
avglist = [0]*20
stringavglist = ['']*20
nsta = 5
nclm = 20
nlines = 1300
checklist = ['Stations', '#Trial Number', ' Number of stations',
' Positionx', 'Positiony', 'Positionz', 'ResultantDistance', 'Payload',
'Aggregation size', 'MCS', 'Bitrate(kbps)', 'Throughput',
'Goodput', 'Tx Packets', 'Rx Packets', ' Packet Loss Ratio',
' Mean Delay(ms)', ' Channel Utilization', 'SNR (dB))', 'MostUsed AggregationSize',
' MostChosenMCS',' Aggregated frames', ' Aggregated packets',' retransmitbytes']
checklist2 = ['Stations', '#Trial Number', ' Number of stations',
' Positionx', 'Positiony', 'Positionz', 'Payload',
'Aggregation size', 'MCS', 'Bitrate(kbps)', 'Throughput',
'Goodput', 'Tx Packets', 'Rx Packets', ' Packet Loss Ratio',
' Mean Delay(ms)', ' Channel Utilization', 'SNR (dB))', 'MostUsed AggregationSize',
' MostChosenMCS',' Aggregated frames', ' Aggregated packets',' retransmitbytes']#, 'Station 0', 'Station 1','Station 2', 'Station 3', 'Station 4', 'Station 5', 'Station 6','Station 7', 'Station 8', 'Station 9'
checkstation = ['Station 0', 'Station 1','Station 2', 'Station 3', 'Station 4', 'Station 5',
'Station 6','Station 7', 'Station 8', 'Station 9']
with open('WalkRandomRFRaggregationprop5stations.csv', 'r') as csvfile:
csvreader = csv.reader(csvfile)
i = 0
with open('WalkRandomRFRaggregationprop5stationsavg.csv', 'w') as newcsv:
csvwriter = csv.writer(newcsv)
for i, row in enumerate(csvreader):
if not row[0] in (None, ""):
for col in range(0,nclm):
if row[col] not in checklist2:
if row[col] == '-nan':
avglist[col] += 0.0
else:
try:
avglist[col] += float(row[col])
except ValueError:
continue
if i == 0:
#csvwriter.writerow(row)
print(1)
elif i != 0 and row[0] not in checklist:
#csvwriter.writerow(row)
print(1)
if i == nlines:
print(avglist)
break
else :
for ncol in range(0, nclm):
if ncol == 19:
avglist[ncol] = avglist[ncol]
stringavglist[ncol] = str(avglist[ncol])
else:
avglist[ncol] = avglist[ncol]/nsta
stringavglist[ncol] = str(avglist[ncol])
stringavglist[0]='Average'
csvwriter.writerow(stringavglist)
if avglist[1]==10:
csvwriter.writerows('\n')
csvwriter.writerows('\n')
csvwriter.writerows('\n')
csvwriter.writerows('\n')
avglist = [0]*nclm
stringavglist = ['']*nclm
i += 3
print(i)
if i == nlines:
print("HELLo")
for ncol in range(0, nclm):
if ncol == 19:
avglist[ncol] = avglist[ncol]
stringavglist[ncol] = str(avglist[ncol])
else:
avglist[ncol] = avglist[ncol]/nsta
stringavglist[ncol] = str(avglist[ncol])
stringavglist[0]='Average'
csvwriter.writerow(stringavglist)
if avglist[1]==10:
csvwriter.writerows('\n')
csvwriter.writerows('\n')
csvwriter.writerows('\n')
csvwriter.writerows('\n')