Skip to main content

Command Palette

Search for a command to run...

How to Convert Strings to Wikidata QIDs

Updated
How to Convert Strings to Wikidata QIDs

TLDR: I made a tool to do this: Wikidata string to QID tool (source).

Bulk adding information to Wikidata by hand is a pain. I have an idea for creating a map of MVNOs (mobile virtual network operators) and their ownership (AT&T owns Cricket, Verizon owns Visible and many brands, T-Mobile owns Mint), like this map of food brands. I want it to be powered by Wikidata so it will update automatically and group together all the MVNOs based on who owns them and what network they run on. Since I'm focusing on the U.S., I needed to add the country field to every MVNO that didn't have it it.

I used Gemini (in Google Sheets) to extract the country name from the description of about 20 MVNOs that I queried from Wikidata. I wanted to add them using QuickStatements, a tool to bulk update Wikidata, but I couldn't get the string of the country to convert to a proper QID. I could do it manually but I wanted to get better at using Quickstatments. It may have supported functionality long ago, but doesn’t anymore, likely because there is always a chance of incorrect matches when using just the string. Georgia the state and Georgia the country are a classic example of why a bit more context is needed for accuracy.

Thankfully, my friend Drini showed me Wikipedia and Wikidata Tools, a Google Sheets extension that lets you do this query as simply as =WIKIDATAQID("en:Spain"). It works decently, but giving a tool access to your account, readings the docs, and being dependent on Google aren't ideal.

To solve this, I created a Wikidata string to QID tool (source). Paste in a list of strings and get a list QIDs. It also shows the description so you can feel more confident in the match and go about your merry way editing Wikidata.

I also went ahead and updated the Wikidata QuickStatements page with some information about this, since it was not very easy to find.

To help people find this on the web, here are some of the ways I searched for this:

  • How can I turn text into a Wikidata QID?
  • How to add a string as the value of a property using QuickStatements for Wikidata?
  • Resolving a string to the corresponding Wikidata ID
T
Tom W5mo ago

Thanks for this! It would be useful to indicate whether the search term is unique. For example, "Abercorn" is the name for at least nine Wikidata entries, but your tool just returns the first.