-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathselectNode.py
More file actions
65 lines (60 loc) · 1.56 KB
/
selectNode.py
File metadata and controls
65 lines (60 loc) · 1.56 KB
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
# -*-coding: utf-8 -*-
from NSE_Analytics_pilot_testing.process import *
import re
def check(overview,line,day):
i = 0
if tuple([int(line), day]) in overview['Home'] and tuple([int(line), day]) in overview['School']:
i += 1
else:
print "No Home or School"
regAm_mode = re.compile(r"'am_mode':\s\[.*?\],")
matchMode = regAm_mode.search(str(overview))
if matchMode!=None:
if len(matchMode.group())!=12:
i += 1
else:
print matchMode.group(),len(matchMode.group())
regPm_mode = re.compile(r"'pm_mode':\s\[.*?\]")
matchMode = regPm_mode.search(str(overview))
if matchMode!=None:
if len(matchMode.group())!=12:
i += 1
else:
print matchMode.group(),len(matchMode.group())
if i == 3:
return True
else:
return False
if __name__=="__main__":
dateList = ["2015-09-28","2015-09-29","2015-09-30","2015-10-01","2015-10-02"]
fr = open("all_Node","r")
fnode = open("Selected_Node","a")
#nodelist = ["510132"]
TagFile = open("TagFile","r")
Tag = TagFile.readline()
print Tag
Tag = int(Tag)
TagFile.close()
count = 0
for line in fr.readlines():
if count < Tag:
count += 1
continue
fw = open("allNodeFile.csv","w")
fw.write(str(line))
fw.close()
print "Node: ",line
i = 0
for day in range(len(dateList)-1):
print dateList[i+1]
overview, geojson = main("https://data.nse.sg","allNodeFile.csv",dateList[i+1],testing = True)
print overview
if check(overview,line,dateList[i]):
i += 1
if i==4 :
fnode.write(str(line)+"\n")
print ""
count += 1
TagFile = open("TagFile","w")
TagFile.write(str(count))
TagFile.close()