I have a file full of SPARQL queries like the following:

* prefix dbpr: <http://dbpedia.org/resource/> prefix dbpo: 
<http://dbpedia.org/ontology/> prefix dbpp: <http://dbpedia.org/property/> 
SELECT distinct ?name ?province ?population ?c from <http://dbpedia3.9> 
where { ?c dbpp:nativeName ?name . ?c dbpo:abstract ?province . ?c 
dbpp:populationTotal ?population . ?city dbpo:isPartOf ?c . ?c dbpo:country 
?land. FILTER (regex (str(?city), "amsterdam", "i") && regex(str(?land), 
"Netherlands")&& langMatches(lang(?province), 'nl')) } *

Is there a way I can extract the *subject, predicate and object (triples) *from 
queries like this, using rdflib?

I'm iterating the file line by line, and I suppose I'd need to parse them 
somehow to get the result I'm looking for. Tried something like the 
following but no luck:


















*from rdflib import Graphg = Graph()with open('queries.tsv') as f:    while 
True:      line = f.readline()      if not line:          break            
  try:        qres = g.query(line)        for row in qres:          
print(row)            except:        print("Cannot parse line")*

I'm certainly missing something fundamental, as I'm new in this field, and 
I was hoping you could help me find my way around.

-- 
http://github.com/RDFLib
--- 
You received this message because you are subscribed to the Google Groups 
"rdflib-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rdflib-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rdflib-dev/dabfe384-43e3-4221-8e94-56b36dd81c3dn%40googlegroups.com.

Reply via email to