Skip to content

Instantly share code, notes, and snippets.

@ashepherd
Created March 6, 2023 22:01
Show Gist options
  • Save ashepherd/62f926396d000c2d5409764c80d14e35 to your computer and use it in GitHub Desktop.
Save ashepherd/62f926396d000c2d5409764c80d14e35 to your computer and use it in GitHub Desktop.
Use RDFLib to convert triples to quads
import rdflib
cg = rdflib.ConjunctiveGraph()
g = rdflib.Graph(cg.store, 'urn:bcodmo:dataset:3300')
g.parse('https://www.bco-dmo.org/node/3300/rdf/xml', format='xml')
serialization = cg.serialize(format='nquads')
print(serialization)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment