I have a couple of files out of which I have to make an RDF graph. Instead of parsing each file again and again by having to write the name of the files, I tried to use the following code:
from rdflib import Graph
g = Graph()
import os
directory = r'/content'
for filename in os.listdir(directory):
if filename.endswith(".ttl"):
name = os.path.join(directory, filename)
g.parse(name, format='turtle')
I get an error:
File "<string>", line unknown
BadSyntax
Can anyone please point out my mistake here and correct my code so that I can accomplish my target