-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTransformer.py
67 lines (48 loc) · 1.64 KB
/
Transformer.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
from PoliceData import getGeoInfo
import json
import re
import pandas as pd
def idSuburb():
with open('suburbs2.json') as f:
suburbs = json.load(f)
# pattern = re.compile("mt")
root = {}
for i in suburbs:
temp = {}
for ii in suburbs[i]:
print (ii)
suburb = ii.lower()
# if pattern.match(suburb) != None:
suburb = suburb.replace("mt","mount")
profile = getGeoInfo(suburb)
# print(profile)
for j in profile["Result"]:
if "LGA" in j:
print (j)
print (j["LGA"])
print (j["Name"])
if j["LGA"] == "BRISBANE CITY" and j["Name"]== suburb.upper():
print (j["QldSuburbId"])
temp[j["QldSuburbId"]] = suburb
root[i] = temp
with open('suburbID.json', 'w') as outfile:
json.dump(root, outfile)
def getMeshSubrubRelation():
dataframe = pd.read_csv("./datasets_csv/All_datas.csv",usecols=[1,3])
arr = dataframe.as_matrix()
meshSuburbs = {}
for i in arr:
if i[1] not in meshSuburbs:
a = set()
a.add(i[0])
meshSuburbs[i[1]] = a
else:
temp = meshSuburbs[i[1]]
temp.add(i[0])
meshSuburbs[i[1]] = temp
for i in meshSuburbs:
meshSuburbs[i] = list(meshSuburbs[i])
print(meshSuburbs)
with open('meshSuburbs.json', 'w') as outfile:
json.dump(meshSuburbs, outfile)
getMeshSubrubRelation()