Skip to content
Tool to match strings to Wikidata items
Python
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
test
wdtool
.gitignore
LICENSE.txt
README.md
wdtool.py

README.md

wdtool.py

Command line utility to match strings to Wikidata items, written in Python 3

Examples

To match strings, first get a CSV file with QID's that you want to match (e.g., from the Wikidata Query Service) and get the metadata for all items

wdtool.py import -i query.csv

If your CSV file has multiple columns and a header, you need to give it the key of the column where your qids are located as well

wdtool.py import -i query.csv -k item --has-header

This will download all item data and write it to a JSON file, by default in a directory called data in the same folder as where you execute wdtool.py.

To match your CSV file of strings try

wdtool.py reconcile -i strings.csv -o strings-matched.csv

strings-matched.csv will contain the effort wdtool has made.

Troubleshooting

  • Before opening an issue, try running your command with the -v (verbose) switch, because this will give you more debug information.

All options

You'll get this output when running wdtool.py -h.

usage: wdtool.py [-h] [--has-header] -i INPUT [-k KEY] [-o OUTPUT]
                 [-dp DATA_PATH] [-v]
                 [{import,reconcile}]

Tool to match strings to Wikidata items

positional arguments:
  {import,reconcile}

optional arguments:
  -h, --help            show this help message and exit
  --has-header          CSV file has a header
  -i INPUT, --input INPUT
                        Input CSV file
  -k KEY, --key KEY     If a CSV file has multiple columns, give the key of
                        the column
  -o OUTPUT, --output OUTPUT
                        Output CSV file
  -dp DATA_PATH, --data-path DATA_PATH
                        Path where the JSON Wikidata files will be saved,
                        defaults to /Users/hkrane01/htdocs/wdtool/data
  -v, --verbose         Display debug information

License

Licensed under the MIT license.

Credits

Written by Hay Kranen.

You can’t perform that action at this time.