MCPcopy Create free account
hub / github.com/comaps/comaps / load_data

Function load_data

tools/python/city_radius.py:11–42  ·  view source on GitHub ↗
(path)

Source from the content-addressed store, hash-verified

9 return s.strip('\t\n ')
10
11def load_data(path):
12
13 global cities
14
15 f = open(path, 'r')
16 lines = f.readlines()
17 f.close();
18
19 for l in lines:
20
21 if l.startswith('#'):
22 continue
23
24 data = l.split('|')
25
26 if len(data) < 6:
27 continue
28
29 item = {}
30
31 item['name'] = strip(data[0])
32 item['population'] = int(strip(data[1]))
33 item['region'] = strip(data[2])
34 item['width'] = float(strip(data[3]))
35 item['height'] = float(strip(data[4]))
36
37 item['square'] = float(data[5])
38
39 cities.append(item)
40
41 # build plot
42 print "Cities count: %d" % len(cities)
43
44def formula(popul, base = 32, mult = 0.5):
45 #return math.exp(math.log(popul, base)) * mult

Callers 1

city_radius.pyFile · 0.85

Calls 3

stripFunction · 0.85
closeMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected