comparison globalneighbors/schema.py @ 1:1b94f3bf97e5

* limit distance function * start gridding * improve unicode handling
author Jeff Hammel <k0scist@gmail.com>
date Sat, 24 Jun 2017 14:02:14 -0700
parents 5dba84370182
children
comparison
equal deleted inserted replaced
0:5dba84370182 1:1b94f3bf97e5
67 67
68 # Keys we care about 68 # Keys we care about
69 name = 'asciiname' 69 name = 'asciiname'
70 primary_key = 'geonameid' 70 primary_key = 'geonameid'
71 71
72 # fields that should be unicode
73 unicode_fields = ('name', 'asciiname')
72 74
73 def cast_row(row, types=types): 75 def cast_row(row, types=types):
74 """ 76 """
75 cast an iterable `row` of data to 77 cast an iterable `row` of data to
76 a `dict` according to `types` casting rule 78 a `dict` according to `types` casting rule
88 # TODO make this configurable 90 # TODO make this configurable
89 if not value and key in ('elevation',): 91 if not value and key in ('elevation',):
90 retval[key] = None 92 retval[key] = None
91 else: 93 else:
92 raise 94 raise
95 if key in unicode_fields:
96 retval[key] = retval[key].decode('utf-8')
93 return retval 97 return retval