Created
December 20, 2019 16:01
-
-
Save sam-drew/9e7c8e37277f37224fc1905a8d663b66 to your computer and use it in GitHub Desktop.
Convert string coordinates to a coord object.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import json | |
| data = None | |
| extractedData = [] | |
| with open("airport-codes_json.json", "r") as read_file: | |
| data = json.load(read_file) | |
| for item in data: | |
| if item["iata_code"] != None and (item["type"] == "large_airport" or item["type"] == "medium_airport"): | |
| extractedData.append(item) | |
| for airport in extractedData: | |
| coordString = airport["coordinates"] | |
| result = [x.strip() for x in coordString.split(',')] | |
| airport["coordinates"] = { | |
| "lat": float(result[1]), | |
| "lon": float(result[0]), | |
| } | |
| with open("iata_only_med_large_only.json", "w") as write_file: | |
| json.dump(extractedData, write_file) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment