Skip to content

Instantly share code, notes, and snippets.

@epoz
Created August 2, 2022 11:05
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 epoz/c5faca2eb514f7d0dde0843e181a548c to your computer and use it in GitHub Desktop.
Save epoz/c5faca2eb514f7d0dde0843e181a548c to your computer and use it in GitHub Desktop.
from rdflib import *
from rich.progress import track
hydra_graph = Graph()
hydra_graph.parse(
"https://nfdi4culture.de/resource.ttl?tx_lod_api[limit]=999&tx_lod_api[page]=1"
)
output_graph = Graph()
resources = [
str(s)
for s, p, o in hydra_graph.triples((None, None, None))
if s.startswith("https://nfdi4culture.de/resource/E") and s.endswith(".ttl")
]
print(f"There are {len(resources)} resources")
for resource in track(resources):
output_graph.parse(resource)
print("Serializing")
open("nfdico.ttl", "w").write(output_graph.serialize(format="turtle"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment