Skip to content
Advertisement

Running SPARQL Queries on turtle file

I’m trying to run SPARQL queries on turtle files using python, but my sparql returns all the entries, how can I return the entry with name=”Idham Al-Taif Mahmoud”?

turtle file:

JavaScript

python code:

JavaScript

Advertisement

Answer

I think your issue is with the methods. Here is a link with a nice example of what you want to do.

The following script works for me:

JavaScript

Notice that I assign the results of the query to a new variable qres, and also that the parse method is void, i.e. it does not return a value like you had.

The % signs in the end are just to print a human readable result, but you can totally get rid of them.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement