Reputation: 1044
This is a follow-up question from How to prevent triples from getting mixed up while uploading to Dydra programmatically?
I've created a new graph using SPARQL CONSTRUCT query. I now want to iterate over it so that I can add the statements to an RDFlib graph and then insert the data into another triplestore. I have the following questions:
'type'
of 'output'
shows up as string. This is my code:
sesameSparqlEndpoint = 'http://my.ip.ad.here:8080/openrdf-sesame/repositories/rep_name'
sparql = SPARQLWrapper(sesameSparqlEndpoint)
queryStringDownload = 'CONSTRUCT {?s ?p ?o} WHERE {?s ?p ?o FILTER REGEX(str(?s), "http")}'
dataGraph = Graph()
sparql.setQuery(queryStringDownload)
sparql.method = 'GET'
sparql.setReturnFormat(JSON)
output = sparql.query().convert()
# print output
#Print all statements in dataGraph
for stmt in output:
print stmt
This code just gives me a single column of characters from the triples.
Upvotes: 1
Views: 1258
Reputation: 1044
Interesting aside: The type(output) when using XML is Conjunctive Graph. For everything else I tried, it's a string.
Upvotes: 0