Skip to content

Instantly share code, notes, and snippets.

@lo5an
Last active May 6, 2016 20:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save lo5an/c8232e8e421e2a6fdedd2ca50f5190b5 to your computer and use it in GitHub Desktop.
Save lo5an/c8232e8e421e2a6fdedd2ca50f5190b5 to your computer and use it in GitHub Desktop.
import json
import csv
with open("authors.json") as authors_json, open("authors.csv", "w+") as authors_csv:
authordata = json.load(authors_json)
authorwriter = csv.writer(authors_csv, delimiter=',',
quotechar='"', quoting=csv.QUOTE_ALL)
for authoruri, value in authordata.items():
row=[]
row.append(authoruri[26:-5]) # id from uri
row.append(authoruri[:-5]) # uri without json format specifyer
names=[]
for item in value['http://www.w3.org/2000/01/rdf-schema#label'] :
names.append(item['value']) # all labels for author
row.append("|".join(names))
authorwriter.writerow(row)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment