Created
July 21, 2016 18:45
-
-
Save JaimieMurdock/0e85bf8b654ec2be4485e95d5006a69b to your computer and use it in GitHub Desktop.
This file contains 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
{ "@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" } ] } | |
] } |
This file contains 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 | |
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