def read(file_name): school_list = [] with open(file_name) as f: data=json.load(f) gmaps = googlemaps.Client(key='my google key') for o in data: try: geocode_result = gmaps.geocode(o['Skolenhetsnamn']) location=geocode_result[0]["geometry"]["location"] except IndexError: pass lat=location.get ("lat","0.0") lng=location.get("lng","0.0") school = School(o['Skolenhets-kod'], o['Skolenhetsnamn'], o['Kod'], o['Kommun'],lat,lng) school_list.append(school) return school_list
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)