-
Notifications
You must be signed in to change notification settings - Fork 0
/
society.py
52 lines (44 loc) · 1.38 KB
/
society.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
#-*- coding:utf-8 -*-
import csv
import base
def get_dict_block_park():
'''
deal with society.csv
'''
#read society.csv
society_csvfile=open('./society.csv','r',encoding='utf-8')
dict_society = csv.DictReader(society_csvfile)
list_society = []
for item in dict_society:
list_society.append(item)
society_csvfile.close()
#print (list_society)
'''
save blocks' name in list_block_name as a list
'''
list_block_name=[]
for society in list_society:
if society['街道名称'] not in list_block_name:
list_block_name.append(society['街道名称'])
#print (list_block_name)
'''
save blocks' park in dict_block_park as a dict
'''
dict_block_park={}.fromkeys(list_block_name,0)
#print(dict_block_greenland)
for area in list_society:
dict_block_park[area['街道名称']]+=float(area['公园服务面积(平方公里)'])
#print (dict_block_park)
return dict_block_park
def socefficiency_value():
'''
calculate total social efficiency
'''
dict_temp = base.get_dict_block_area()
dict_socefficiency_value = {}
dict_block_park = get_dict_block_park()
for key in dict_block_park:
dict_socefficiency_value[key] = dict_block_park[key] \
/ dict_temp[key]
#print (dict_socefficiency_value)
return dict_socefficiency_value