import json with open("raw.json", "r") as f: string = f.read() rawls = json.loads(string) latlons = [{'lat': x['lat'], 'lon': x['lon']} for x in rawls if x['lon'] != None] with open("pos.json", "w") as w: w.write(json.dumps(latlons))