Not an Issue : regarding documentation on using Wikidata
sobalgi opened this issue · comments
Hello,
Firstly this is not an issue with the code. Sorry for posting this under issues.
I wanted to get some additional documentation on using the module.
Suppose I want get a list of all the entities with a certain property.
The current documentation Wikidata client library for Python only shows how to get a property given an entity.
I'm trying to find if I can get a list of entities with the mentioned property.
e.g. get a list of countries (entities) given the property for country 'P17'.
I'm not sure if this already exists. Please let me know if it exists.
I would appreciate if the module had an improved documentation Issue #10 .
Thanks,
@sobalgi.
You can do that with SPARQL queries. You can play with your query on https://query.wikidata.org then use pywikibot
to run it in Python.
from pywikibot.data.sparql import SparqlQuery
q = SparqlQuery("SELECT ...")
for item in q:
# do something
...
I don’t know if the wikidata
module allows you to do that.
You can do that with SPARQL queries. You can play with your query on https://query.wikidata.org then use
pywikibot
to run it in Python.from pywikibot.data.sparql import SparqlQuery q = SparqlQuery("SELECT ...") for item in q: # do something ...I don’t know if the
wikidata
module allows you to do that.
Updated pywikibot syntax for the anyone googling this:
from pywikibot.data.sparql import SparqlQuery
query = SparqlQuery()
for item in query.select("SELECT ..."):
# do something
...