Mercurial > hg > GlobalNeighbors
view globalneighbors/neighbors.py @ 20:2fef925fbf37
display country + population in autocomplete drop down
author | Jeff Hammel <k0scist@gmail.com> |
---|---|
date | Sun, 25 Jun 2017 16:12:08 -0700 |
parents | |
children | e69cb496324e |
line wrap: on
line source
""" read neighbors file; this should be in the form of: `{geoid: [(geoid_closest_neighbor, distance), (geoid_2nd_closest_neighbor, distance), ...] }` """ import json import os string = (str, basestring) # python2 def read_neighbors_file(f): if isinstance(f, string): with open(f) as _f: return read_neighbors_file(f) retval = {} for line in f: data = json.loads(line) retval.update(data) return retval