Skip to content

Instantly share code, notes, and snippets.

@JaimieMurdock
Created July 21, 2016 18:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JaimieMurdock/0e85bf8b654ec2be4485e95d5006a69b to your computer and use it in GitHub Desktop.
Save JaimieMurdock/0e85bf8b654ec2be4485e95d5006a69b to your computer and use it in GitHub Desktop.
{ "@graph": [
{ "@id": "http://htrc.hathitrust.org/wsid/1616876109a",
"@type" : [ "http://wcsa.htrc.illinois.edu/Workset" ] ,
"http://purl.org/dc/terms/created" : [ { "@value" : "2013-05-01" } ] ,
"http://purl.org/dc/terms/extent" : [ 5 ] ,
"http://www.europeana.eu/schemas/edm/gathers" : [ { "@id": "http://hdl.handle.net/2027/wu.89054391917"} ,
{ "@id": "http://hdl.handle.net/2027/njp.32101067492643"} ,
{ "@id": "http://hdl.handle.net/2027/hvd.hnr43u"} ,
{ "@id": "http://hdl.handle.net/2027/osu.32435014276414"} ,
{ "@id": "http://hdl.handle.net/2027/wu.89107614968"} ] ,
"http://purl.org/dc/terms/creator" : [ { "@value" : "Jesse S Cohn" } ] ,
"http://wcsa.htrc.illinois.edu/intendedForUse" : [ { "@id": "http://example.org/htrc.algorithm"} ] ,
"http://purl.org/dc/terms/title" : [ { "@value" : "Anarchist literary and cultural criticism" } ] ,
"http://purl.org/dc/terms/language" : [ { "@value" : "French" } ,
{ "@value" : "Czech" } ] ,
"http://purl.org/dc/terms/temporal" : [ { "@value" : "19th Century" } ] }
] }
import json
import sys
WORKSET_BASE_URL = 'http://htrc.hathitrust.org/wsid/'
# TODO: Replace with argument parsing
WORKSET_ID = '1616876109'
# open the JSON file or retrieve the URL
with open("BasicWorkset.json") as jsonfile:
data = json.load(jsonfile)['@graph']
ALL_IDS = []
# Parse each graph
for graph in data:
gathers = graph.get("http://www.europeana.eu/schemas/edm/gathers", [])
ids = [entry['@id'].replace('http://hdl.handle.net/2027/', '')
for entry in gathers]
if ids:
ALL_IDS.extend(ids)
for id in ALL_IDS:
print id
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment