import ox from geo import read_json, read_table geo = { 'keys': read_json('../json/oxjs.org/geonames.keys.json') #'levels': read_json('../json/oxjs.org/levels.json') } def get_countries(): return get_data('country', 'countryInfo', 'ISO') def get_data(type, file, sort_key): keys = geo['keys'][type]['geonames.org'] sort = lambda x: x[sort_key] data = read_table('http://download.geonames.org/export/dump/' + file + '.txt', keys, sort=sort) return data def get_languages(): return get_data('language', 'iso-languagecodes', 'ISO_639-3')