-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdataExtract.py
70 lines (63 loc) · 2.4 KB
/
dataExtract.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
apCentral = []
apClassroom = []
apKitchen = []
apEntrance = []
apGallery = []
ap13B9 = []
ap16B9 = []
ap17B9 = []
currentList = ""
def write(line, currentList) :
if currentList == "apClassroom" :
apClassroom.append(line[:-1])
elif currentList == "apKitchen" :
apKitchen.append(line[:-1])
elif currentList == "apEntrance" :
apEntrance.append(line[:-1])
elif currentList == "apCentral" :
apCentral.append(line[:-1])
elif currentList == "apGallery" :
apGallery.append(line[:-1])
elif currentList == "ap13B9" :
ap13B9.append(line[:-1])
elif currentList == "ap16B9" :
ap16B9.append(line[:-1])
elif currentList == "ap17B9" :
ap17B9.append(line[:-1])
else :
print("error")
with open('/home/pi/userByAP/clientData.txt', 'rt') as myfile:
for line in myfile:
if len(line) == 10: #it's the ap header
# print("inloop "+line)
if line[:-1] == "10.1.0.10": #meilleure solution??
currentList = "apClassroom"
elif line[:-1] == "10.1.0.11":
currentList = "apCentral"
elif line[:-1] == "10.1.0.12":
currentList = "apKitchen"
elif line[:-1] == "10.1.0.14":
currentList = "apEntrance"
elif line[:-1] == "10.1.0.13":
currentList = "ap13B9"
elif line[:-1] == "10.1.0.15":
currentList = "apGallery"
elif line[:-1] == "10.1.0.16":
currentList = "ap16B9"
elif line[:-1] == "10.1.0.17":
currentList = "ap17B9"
else :
print("unable to identify AP")
print("test"+line)
else :
write(line,currentList)
#print ("length "+str(len(apClassroom)))
with open('/home/pi/userByAP/influxData2.txt', 'w+') as influx:
influx.write("AP,name=apClassroom value="+str(len(apClassroom))+ "\n")
influx.write("AP,name=apKitchen value="+str(len(apKitchen))+ "\n")
influx.write("AP,name=apEntrance value="+str(len(apEntrance))+ "\n")
influx.write("AP,name=apCentral value="+str(len(apCentral))+ "\n")
influx.write("AP,name=apGallery value="+str(len(apGallery))+ "\n")
influx.write("AP,name=ap13B9 value="+str(len(ap13B9))+ "\n")
influx.write("AP,name=ap16B9 value="+str(len(ap16B9))+ "\n")
influx.write("AP,name=ap17B9 value="+str(len(ap17B9))+ "\n")