Skip to content

Instantly share code, notes, and snippets.

@tmtmtmtm

tmtmtmtm/dobs.md Secret

Last active Aug 1, 2020
Embed
What would you like to do?

Give a table of dates of birth in a Google Sheet:

Wikidata	born	died
Q97971303	1930	2015
Q97971309	1830-06-29	1897-06-03
Q97971315	''	1991-01
Q97971316	1867-01-01	1927-05-07
Q97971318	''	1982
Q97971319	''	1981
Q97971320	1918-11-28	2014-05-14
Q97971321	''	1706-03-13
Q97971323	''	1885-03-30
Q97971324	1925-09-29	1934-04-20
Q97971325	1921	1945-10-04
Q97971326	1799	1892-02-16
Q97971327	''	1889
Q97971328	''	2006
Q97971330	1922	2003-05
Q97971331	''	1787-08-01
Q97971333	1929	1988-05-06
Q97971336	''	1919
Q97971337	1922-11-13	2010-04-01
Q97971338	1878	1908-12-28
Q97971340	1845-08-14	1898-04-11
Q97971341	1827-07-21	1878-06
Q97971344	1830-10-01	1886-09-30
Q97971345	1943-01-22	2014-02-28
Q97971346	1941	2010
Q97971349	1919	2002

and an add-dates.js template:

module.exports = (id, dob, dod) => {
  const claims = { }
  const wos = { P248: 'Q88552852' } // Women of Scotland

  if (dob && dob != "''")   claims['P569'] = { value: dob, references: wos }
  if (dod && dod != "''")   claims['P570'] = { value: dod, references: wos }

  return {
    id,
    claims: claims
  }
}

Then select the entire set of data, and bulk add everything to Wikidata using:

pbpaste | xargs -n 3 | wd ee add-dates.js --batch --summary "Add birth and death dates from Women in Scotland"

-> https://tools.wmflabs.org/editgroups/b/wikibase-cli/d959b3ae77835/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.