wikidataloader
Easy pythonic wrapper around the Wikidata SPARQL API for quick creation of datasets from Wikidata.
Only supports simple, non-recursive queries - for complex queries please directly use the SPARQL API provided by Wikidata.
It does not support complex operators (ordering, datetime conversion, string/numeric filtering etc.), because these can be substituted by preprocessing the dataset in Python after retrieval.
Usage
Look up the URIs for properties (e.g. P31) and objects (e.g. Q5) on Wikidata's search engine.
from wikidataloader import WikidataQuery
# Linguists from Germany with birth places and gender
results = WikidataQuery.search(
# {is_instance:human, country_of_origin:Germany, profession:linguist}
filters={"P31": "Q5", "P27": "Q183", "P106": "Q14467526"},
# selects the properties "Gender" and "Birth Place" as columns in the dataframe and names them "Gender" and "City of Birth"
select=[("P21", "Gender"), ("P19", "City of Birth")],
# returns a maximum of 5 results
limit=5,
# retrieves labels in English, if available
default_language="en"
).to_pandas()
results
>>> item Gender City_of_Birth
>>> 0 Hermann Weller male Schwäbisch Gmünd
>>> 1 Hans Wehr male Leipzig
>>> 2 Theodor Haecker male Mulfingen
>>> 3 Gottfried Bernhardy male Gorzów Wielkopolski
>>> 4 Wilhelm Streitberg male Rüdesheim am Rhein
For more examples, see example.ipynb
Install
Install using pip:
pip install wikidataloader
Limitations
- Does not support recursive queries
- Does not support Senses and Forms for Lexeme queries
Metadata
Release files for wikidataloader 0.0.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| wikidataloader-0.0.7.tar.gz | 17.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| wikidataloader-0.0.7-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 35.4 kB
Release files / wikidataloader-0.0.7.tar.gz
| Download URL | wikidataloader-0.0.7.tar.gz |
|---|---|
| Size | 17.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
276df73683d08f1fc1b0db6f7d2255735bffec427bf8cdcb115949cbd8c14454
|
|
BLAKE2b-256 checksum How to use checksums |
1c70c5159b9a3b2ebf7c6a8b9372a4538bf0c6bece3ee50d524a90b88526c634
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|
Release files / wikidataloader-0.0.7-py3-none-any.whl
| Download URL | wikidataloader-0.0.7-py3-none-any.whl |
|---|---|
| Size | 17.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
93be3f6c51e9861c980b0b2044098c36815d5161ec56bd541014b70f634135b3
|
|
BLAKE2b-256 checksum How to use checksums |
dffb1f7921b60e4ca7ead565869475673eaf1e08d22dc4413359cf68dcd11897
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|