(path)
| 9 | return s.strip('\t\n ') |
| 10 | |
| 11 | def 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 | |
| 44 | def formula(popul, base = 32, mult = 0.5): |
| 45 | #return math.exp(math.log(popul, base)) * mult |
no test coverage detected