Skip to main content

Pythonic wrapper around the Wikidata SPARQL API for quick creation of datasets from Wikidata

Project description

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

results = WikidataQuery.search(
    filters={"P31": "Q5", "P27": "Q183", "P106": "Q156839"}, # {is_instance: human, country_of_origin: Germany, profession: cook}
    select=[("P21", "Gender"), ("P19", "City of Birth")],
    limit=30,
	default_language="en"
)

results.to_pandas()

For more examples, see example.ipynb

Install

Install using pip:

pip install wikidataloader

Limitations

  • Does not support recursive queries
  • Does not support labels for Lexeme queries

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wikidataloader-0.0.1.tar.gz (16.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wikidataloader-0.0.1-py3-none-any.whl (17.1 kB view details)

Uploaded Python 3

File details

Details for the file wikidataloader-0.0.1.tar.gz.

File metadata

  • Download URL: wikidataloader-0.0.1.tar.gz
  • Upload date:
  • Size: 16.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for wikidataloader-0.0.1.tar.gz
Algorithm Hash digest
SHA256 f8f37e89004ac96776a10bac66d35e39623365d008c3790eb0a350ea6c5ef2c3
MD5 45d4e800b5ba2063ca21a1873e8f1151
BLAKE2b-256 11d434d64b1a439f974f56ac89c4b7733b304ea31872c8c07120021b634c529a

See more details on using hashes here.

File details

Details for the file wikidataloader-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: wikidataloader-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 17.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for wikidataloader-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5c76336d2c18f07d6d169a9f8b39d89ab962a83953f21ba7b3ca82f537c36a88
MD5 70c89f84771019ec121d51c331a244ba
BLAKE2b-256 ce3dc301503ca18bc3eb77a25047f430adc9c30a8640ae01731b539e87e7025c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page