Created
January 29, 2021 20:52
-
-
Save epoz/c4d150014732e95eefd44a74593e6a36 to your computer and use it in GitHub Desktop.
Scan a NDJSON file of JSON-LD data and convert it to Turtle
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
# Make sure you have the rdflib and rdflib-jsonld libraries installed | |
# This gist is the Pythn equivalent of Mark's repo from here: https://github.com/mightymax/ndjson2ttl | |
# As referenced in this tweet: https://twitter.com/markuitheiloo/status/1355252255327449090 | |
import sys | |
from rdflib import Graph | |
for line in open(sys.argv[1]): | |
g = Graph().parse(data=line, format="json-ld") | |
print(g.serialize(format="n3").decode("utf8")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can run the script above by calling it with the file to convert as the first argument, for example:
python ndjson2nt.py iconclass.ndjson