Skip to content

Instantly share code, notes, and snippets.

@paregorios
paregorios / findit.py
Last active April 3, 2017 11:48
How to find all Pleiades URIs that correspond to a Trismegistos place URI
# read in the json and get the graph of places
import json
with open('pleiades-places-latest.json', 'r', encoding='utf-8') as f:
pj = json.load(f)
graph = pj['@graph']
# iterate through the graph and test each place for a TM reference
for place in graph:
references = place['references']
tm_geoids = [r['accessURI'] for r in references if 'trismegistos' in r['accessURI']]