Reputation: 159
I have a .ttl file which consists of 3 attributes.
Ex: <http://dbpedia.org/resource/James_B._McLeran> <http://www.w3.org/2000/01/rdf-schema#label> "James B. McLeran"@en .
How can I parse and store these attributes using RDFlib?
Expected output: subject = <http://dbpedia.org/resource/James_B._McLeran>
predicate = <http://www.w3.org/2000/01/rdf-schema#label>
object = "James B. McLeran"@en .
Upvotes: 2
Views: 1106
Reputation: 21
from rdflib import Graph
g = Graph()
g.parse("http://downloads.dbpedia.org/something.ttl", format="turtle")
for triple in g:
print(
"""
subject = {}
predicate = {}
object = {}
""".format(*triple)
)
Upvotes: 1