-
Notifications
You must be signed in to change notification settings - Fork 9
/
MapMaker.py
55 lines (43 loc) · 1.71 KB
/
MapMaker.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
import pandas as pd
citys = pd.read_excel(r'data.xlsx', sheet_name=0)
origin=citys['城市'].values
flyGeo=citys['城市经纬度'].values
flyVal = citys['人数'].values
schools = pd.read_excel(r'data.xlsx', sheet_name=1)
schoolName = schools['学校'].values
schoolGeo = schools['学校经纬度'].values
studentName = schools['学生姓名'].values
print(origin, flyGeo, flyVal)
print(schoolName, schoolGeo, studentName)
replaceOrigin = origin[0]
replaceFlygeo = ''
for i in range(len(origin)):
s = "'{}':[{:.2f}, {:.2f}],".format(origin[i], float(flyGeo[i].split(',')[0]), float(flyGeo[i].split(',')[1]))
print(s)
replaceFlygeo += s
replaceFlyVal=''
for i in range(len(origin)):
s = "[{{name:'{}'}}, {{name:'{}', value:{:d}}}],".format(origin[i], replaceOrigin, int(flyVal[i]))
print(s)
replaceFlyVal += s
print(replaceFlygeo)
replaceScatterGeo = ''
for i in range(len(schoolName)):
s = '"{}":[{:.2f}, {:.2f}],'.format(schoolName[i], float(schoolGeo[i].split(',')[0]), float(schoolGeo[i].split(',')[1]))
print(s)
replaceScatterGeo += s
replaceScatterVal= ''
for i in range(len(schoolName)):
s = '{{name:"{}", value:"{}"}},'.format(schoolName[i], studentName[i])
print(s)
replaceScatterVal += s
a = open(r'temp.html', 'r', encoding='utf-8')
string = a.read()
string = string.replace('replaceOrigin', replaceOrigin)
string = string.replace('replaceFlyGeo', replaceFlygeo)
string = string.replace('replaceFlyVal', replaceFlyVal)
string = string.replace('replaceScatterGeo', replaceScatterGeo)
string = string.replace('replaceScatterVal', replaceScatterVal)
b = open(r'index.html', 'w', encoding= 'utf-8')
b.write(string)
b.close()