Skip to content

Instantly share code, notes, and snippets.

@compustar
Last active February 9, 2020 07:39
Show Gist options
  • Save compustar/5168e084c83b2732b62842e489f59b57 to your computer and use it in GitHub Desktop.
Save compustar/5168e084c83b2732b62842e489f59b57 to your computer and use it in GitHub Desktop.
Python script parses Google Map JSON and convert it to Excel parsable JSON
import json
def get_layers(data):
return data[1][6]
def get_items(data):
return data[12][0][13][0]
def parse_item(item):
output = {"latitude": item[1][0][0][0],
"longitude": item[1][0][0][1]}
output[item[5][0][0]] = item[5][0][1][0]
for a in item[5][3]:
output[a[0]] =a[1][0]
return output
if __name__ == "__main__":
f = open("data.json", "r", encoding="utf8")
data = f.read()
f.close()
data = json.loads(data)
layers = get_layers(data)
items = get_items(layers[-1])
items = [parse_item(x) for x in items]
output = json.dumps(items)
f = open("data_.json", "w", encoding="utf8")
f.write(output)
f.flush()
f.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment