Created
January 28, 2020 16:32
-
-
Save salgo60/2de5881f88989df60f701b31408d6ff6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# pip install sparqlwrapper | |
# https://rdflib.github.io/sparqlwrapper/ | |
from SPARQLWrapper import SPARQLWrapper, JSON | |
endpoint_url = "https://query.wikidata.org/sparql" | |
query = """SELECT ?sculptors (REPLACE(STR(?sculptors),".*Q","Q") AS ?WD) ?sculptorsLabel ?birth ?died ?sculptorsDescription WHERE { | |
VALUES ?sculptors { wd:Q4936564 wd:Q5908201 wd:Q4938072 wd:Q15711231 wd:Q4966391 wd:Q4939597 wd:Q16596588 | |
wd:Q4952238 wd:Q2827030 wd:Q4970016 wd:Q4970058 wd:Q4935445 wd:Q20156198 wd:Q4981273 | |
wd:Q4967393 wd:Q4970058 wd:Q4942419 wd:Q4948953 wd:Q4941548 wd:Q23989466 wd:Q18274990 | |
wd:Q4953594 wd:Q23989466 wd:Q4976986 wd:Q4972692 wd:Q517138 wd:Q22338471 wd:Q4960550 | |
wd:Q23989419 wd:Q48704874 wd:Q27902203 } | |
?sculptors wdt:P569 ?birthDate. | |
?sculptors wdt:P570 ?diedDate | |
minus {?sculptors wdt:P7704 ?EuropeanaID} | |
BIND (SUBSTR(CONCAT("0",STR(DAY(?diedDate))),STRLEN(STR(DAY(?diedDate))),2) AS ?diedDay) | |
BIND (SUBSTR(CONCAT("0",STR(MONTH(?diedDate))),STRLEN(STR(MONTH(?diedDate))),2) AS ?diedMonth) | |
BIND (CONCAT(STR(YEAR(?diedDate)),"-",?diedMonth,"-",?diedDay) AS ?died) | |
BIND (SUBSTR(CONCAT("0",STR(DAY(?birthDate))),STRLEN(STR(DAY(?birthDate))),2) AS ?birthDay) | |
BIND (SUBSTR(CONCAT("0",STR(MONTH(?birthDate))),STRLEN(STR(MONTH(?birthDate))),2) AS ?birthMonth) | |
BIND (CONCAT(STR(YEAR(?birthDate)),"-",?birthMonth,"-",?birthDay) AS ?birth) | |
?sculptors wdt:P569 ?birthDate. | |
SERVICE wikibase:label { bd:serviceParam wikibase:language "en,sv". } | |
} """ | |
def get_results(endpoint_url, query): | |
sparql = SPARQLWrapper(endpoint_url) | |
sparql.setQuery(query) | |
sparql.setReturnFormat(JSON) | |
return sparql.query().convert() | |
results = get_results(endpoint_url, query) | |
for result in results["results"]["bindings"]: | |
print(result) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
{'sculptors': {'type': 'uri', 'value': 'http://www.wikidata.org/entity/Q2827030'}, 'sculptorsLabel': {'xml:lang': 'en', 'type': 'literal', 'value': 'Agnes de Frumerie'}, 'sculptorsDescription': {'xml:lang': 'en', 'type': 'literal', 'value': 'Swedish sculptress'}, 'died': {'type': 'literal', 'value': '1937-04-02'}, 'birth': {'type': 'literal', 'value': '1869-11-20'}, 'WD': {'type': 'literal', 'value': 'Q2827030'}}
{'sculptors': {'type': 'uri', 'value': 'http://www.wikidata.org/entity/Q4935445'}, 'sculptorsLabel': {'xml:lang': 'en', 'type': 'literal', 'value': 'Märta Améen'}, 'sculptorsDescription': {'xml:lang': 'en', 'type': 'literal', 'value': 'Swedish artist, painter, sculptress (1871-1940)'}, 'died': {'type': 'literal', 'value': '1940-06-25'}, 'birth': {'type': 'literal', 'value': '1871-02-28'}, 'WD': {'type': 'literal', 'value': 'Q4935445'}}
{'sculptors': {'type': 'uri', 'value': 'http://www.wikidata.org/entity/Q4936564'}, 'sculptorsLabel': {'xml:lang': 'en', 'type': 'literal', 'value': 'Karin Arosenius'}, 'sculptorsDescription': {'xml:lang': 'en', 'type': 'literal', 'value': 'Swedish sculptress'}, 'died': {'type': 'literal', 'value': '1932-04-03'}, 'birth': {'type': 'literal', 'value': '1851-07-29'}, 'WD': {'type': 'literal', 'value': 'Q4936564'}}
{'sculptors': {'type': 'uri', 'value': 'http://www.wikidata.org/entity/Q4938072'}, 'sculptorsLabel': {'xml:lang': 'en', 'type': 'literal', 'value': 'Carolina Benedicks-Bruce'}, 'sculptorsDescription': {'xml:lang': 'en', 'type': 'literal', 'value': 'Swedish sculptress'}, 'died': {'type': 'literal', 'value': '1935-02-16'}, 'birth': {'type': 'literal', 'value': '1856-10-28'}, 'WD': {'type': 'literal', 'value': 'Q4938072'}}
{'sculptors': {'type': 'uri', 'value': 'http://www.wikidata.org/entity/Q4939597'}, 'sculptorsLabel': {'xml:lang': 'en', 'type': 'literal', 'value': 'Sigrid Blomberg'}, 'sculptorsDescription': {'xml:lang': 'en', 'type': 'literal', 'value': 'Swedish sculptress'}, 'died': {'type': 'literal', 'value': '1941-01-28'}, 'birth': {'type': 'literal', 'value': '1863-10-17'}, 'WD': {'type': 'literal', 'value': 'Q4939597'}}
{'sculptors': {'type': 'uri', 'value': 'http://www.wikidata.org/entity/Q4941548'}, 'sculptorsLabel': {'xml:lang': 'en', 'type': 'literal', 'value': 'Lena Börjeson'}, 'sculptorsDescription': {'xml:lang': 'en', 'type': 'literal', 'value': 'Swedish sculptress'}, 'died': {'type': 'literal', 'value': '1976-04-14'}, 'birth': {'type': 'literal', 'value': '1879-10-13'}, 'WD': {'type': 'literal', 'value': 'Q4941548'}}
{'sculptors': {'type': 'uri', 'value': 'http://www.wikidata.org/entity/Q4942419'}, 'sculptorsLabel': {'xml:lang': 'en', 'type': 'literal', 'value': 'Carola Cederström'}, 'sculptorsDescription': {'xml:lang': 'en', 'type': 'literal', 'value': 'Swedish artist'}, 'died': {'type': 'literal', 'value': '1954-08-06'}, 'birth': {'type': 'literal', 'value': '1878-12-01'}, 'WD': {'type': 'literal', 'value': 'Q4942419'}}
{'sculptors': {'type': 'uri', 'value': 'http://www.wikidata.org/entity/Q4948953'}, 'sculptorsLabel': {'xml:lang': 'en', 'type': 'literal', 'value': 'Sigrid Fridman'}, 'sculptorsDescription': {'xml:lang': 'en', 'type': 'literal', 'value': 'Swedish sculptress'}, 'died': {'type': 'literal', 'value': '1963-01-08'}, 'birth': {'type': 'literal', 'value': '1879-11-23'}, 'WD': {'type': 'literal', 'value': 'Q4948953'}}
{'sculptors': {'type': 'uri', 'value': 'http://www.wikidata.org/entity/Q4952238'}, 'sculptorsLabel': {'xml:lang': 'en', 'type': 'literal', 'value': 'Ellen Roosval von Hallwyl'}, 'sculptorsDescription': {'xml:lang': 'en', 'type': 'literal', 'value': 'Swedish sculptress'}, 'died': {'type': 'literal', 'value': '1952-04-09'}, 'birth': {'type': 'literal', 'value': '1867-07-29'}, 'WD': {'type': 'literal', 'value': 'Q4952238'}}
{'sculptors': {'type': 'uri', 'value': 'http://www.wikidata.org/entity/Q4960550'}, 'sculptorsLabel': {'xml:lang': 'en', 'type': 'literal', 'value': 'Ella Lagerman'}, 'sculptorsDescription': {'xml:lang': 'en', 'type': 'literal', 'value': 'Swedish sculptress'}, 'died': {'type': 'literal', 'value': '1946-10-12'}, 'birth': {'type': 'literal', 'value': '1889-06-08'}, 'WD': {'type': 'literal', 'value': 'Q4960550'}}
{'sculptors': {'type': 'uri', 'value': 'http://www.wikidata.org/entity/Q4966391'}, 'sculptorsLabel': {'xml:lang': 'en', 'type': 'literal', 'value': 'Ida Matton'}, 'sculptorsDescription': {'xml:lang': 'en', 'type': 'literal', 'value': 'Swedish sculptress'}, 'died': {'type': 'literal', 'value': '1940-07-07'}, 'birth': {'type': 'literal', 'value': '1863-02-24'}, 'WD': {'type': 'literal', 'value': 'Q4966391'}}
{'sculptors': {'type': 'uri', 'value': 'http://www.wikidata.org/entity/Q4970016'}, 'sculptorsLabel': {'xml:lang': 'en', 'type': 'literal', 'value': 'Alice Nordin'}, 'sculptorsDescription': {'xml:lang': 'en', 'type': 'literal', 'value': 'Swedish sculptress'}, 'died': {'type': 'literal', 'value': '1948-05-26'}, 'birth': {'type': 'literal', 'value': '1871-05-04'}, 'WD': {'type': 'literal', 'value': 'Q4970016'}}
{'sculptors': {'type': 'uri', 'value': 'http://www.wikidata.org/entity/Q4970058'}, 'sculptorsLabel': {'xml:lang': 'en', 'type': 'literal', 'value': 'Hjördis Nordin-Tengbom'}, 'sculptorsDescription': {'xml:lang': 'en', 'type': 'literal', 'value': 'Swedish sculptress'}, 'died': {'type': 'literal', 'value': '1969-01-11'}, 'birth': {'type': 'literal', 'value': '1877-01-02'}, 'WD': {'type': 'literal', 'value': 'Q4970058'}}
{'sculptors': {'type': 'uri', 'value': 'http://www.wikidata.org/entity/Q4970058'}, 'sculptorsLabel': {'xml:lang': 'en', 'type': 'literal', 'value': 'Hjördis Nordin-Tengbom'}, 'sculptorsDescription': {'xml:lang': 'en', 'type': 'literal', 'value': 'Swedish sculptress'}, 'died': {'type': 'literal', 'value': '1969-01-11'}, 'birth': {'type': 'literal', 'value': '1877-01-02'}, 'WD': {'type': 'literal', 'value': 'Q4970058'}}
{'sculptors': {'type': 'uri', 'value': 'http://www.wikidata.org/entity/Q4970058'}, 'sculptorsLabel': {'xml:lang': 'en', 'type': 'literal', 'value': 'Hjördis Nordin-Tengbom'}, 'sculptorsDescription': {'xml:lang': 'en', 'type': 'literal', 'value': 'Swedish sculptress'}, 'died': {'type': 'literal', 'value': '1969-01-11'}, 'birth': {'type': 'literal', 'value': '1877-01-02'}, 'WD': {'type': 'literal', 'value': 'Q4970058'}}
{'sculptors': {'type': 'uri', 'value': 'http://www.wikidata.org/entity/Q4970058'}, 'sculptorsLabel': {'xml:lang': 'en', 'type': 'literal', 'value': 'Hjördis Nordin-Tengbom'}, 'sculptorsDescription': {'xml:lang': 'en', 'type': 'literal', 'value': 'Swedish sculptress'}, 'died': {'type': 'literal', 'value': '1969-01-11'}, 'birth': {'type': 'literal', 'value': '1877-01-02'}, 'WD': {'type': 'literal', 'value': 'Q4970058'}}
{'sculptors': {'type': 'uri', 'value': 'http://www.wikidata.org/entity/Q4972692'}, 'sculptorsLabel': {'xml:lang': 'en', 'type': 'literal', 'value': 'Anna Petrus'}, 'sculptorsDescription': {'xml:lang': 'en', 'type': 'literal', 'value': 'Swedish sculptress'}, 'died': {'type': 'literal', 'value': '1949-07-26'}, 'birth': {'type': 'literal', 'value': '1886-06-02'}, 'WD': {'type': 'literal', 'value': 'Q4972692'}}
{'sculptors': {'type': 'uri', 'value': 'http://www.wikidata.org/entity/Q4976986'}, 'sculptorsLabel': {'xml:lang': 'en', 'type': 'literal', 'value': 'Ninnan Santesson'}, 'sculptorsDescription': {'xml:lang': 'en', 'type': 'literal', 'value': 'Swedish sculptress and cartoonist'}, 'died': {'type': 'literal', 'value': '1969-01-14'}, 'birth': {'type': 'literal', 'value': '1891-12-14'}, 'WD': {'type': 'literal', 'value': 'Q4976986'}}
{'sculptors': {'type': 'uri', 'value': 'http://www.wikidata.org/entity/Q4981273'}, 'sculptorsLabel': {'xml:lang': 'en', 'type': 'literal', 'value': 'Harriet Sundström'}, 'sculptorsDescription': {'xml:lang': 'en', 'type': 'literal', 'value': 'Swedish artist'}, 'died': {'type': 'literal', 'value': '1961-04-28'}, 'birth': {'type': 'literal', 'value': '1872-12-23'}, 'WD': {'type': 'literal', 'value': 'Q4981273'}}
{'sculptors': {'type': 'uri', 'value': 'http://www.wikidata.org/entity/Q5908201'}, 'sculptorsLabel': {'xml:lang': 'en', 'type': 'literal', 'value': 'Ida Ericson-Molard'}, 'sculptorsDescription': {'xml:lang': 'en', 'type': 'literal', 'value': 'Swedish sculptress'}, 'died': {'type': 'literal', 'value': '1927-01-01'}, 'birth': {'type': 'literal', 'value': '1853-02-13'}, 'WD': {'type': 'literal', 'value': 'Q5908201'}}
{'sculptors': {'type': 'uri', 'value': 'http://www.wikidata.org/entity/Q15711231'}, 'sculptorsLabel': {'xml:lang': 'en', 'type': 'literal', 'value': 'Antoinette Vallgren'}, 'sculptorsDescription': {'xml:lang': 'en', 'type': 'literal', 'value': 'Swedish sculptress'}, 'died': {'type': 'literal', 'value': '1911-07-25'}, 'birth': {'type': 'literal', 'value': '1858-06-05'}, 'WD': {'type': 'literal', 'value': 'Q15711231'}}
{'sculptors': {'type': 'uri', 'value': 'http://www.wikidata.org/entity/Q16596588'}, 'sculptorsLabel': {'xml:lang': 'en', 'type': 'literal', 'value': 'Ida Thoresen'}, 'sculptorsDescription': {'xml:lang': 'en', 'type': 'literal', 'value': 'Swedish sculptress'}, 'died': {'type': 'literal', 'value': '1937-10-29'}, 'birth': {'type': 'literal', 'value': '1863-08-10'}, 'WD': {'type': 'literal', 'value': 'Q16596588'}}
{'sculptors': {'type': 'uri', 'value': 'http://www.wikidata.org/entity/Q18274990'}, 'sculptorsLabel': {'xml:lang': 'en', 'type': 'literal', 'value': 'Elsa Danson Wåghals'}, 'sculptorsDescription': {'xml:lang': 'en', 'type': 'literal', 'value': 'Swedish sculptress'}, 'died': {'type': 'literal', 'value': '1977-03-30'}, 'birth': {'type': 'literal', 'value': '1885-01-13'}, 'WD': {'type': 'literal', 'value': 'Q18274990'}}
{'sculptors': {'type': 'uri', 'value': 'http://www.wikidata.org/entity/Q20156198'}, 'sculptorsLabel': {'xml:lang': 'en', 'type': 'literal', 'value': 'Gerda Sprinchorn'}, 'sculptorsDescription': {'xml:lang': 'en', 'type': 'literal', 'value': 'Swedish ceramist, sculptress'}, 'died': {'type': 'literal', 'value': '1951-03-21'}, 'birth': {'type': 'literal', 'value': '1871-04-29'}, 'WD': {'type': 'literal', 'value': 'Q20156198'}}
{'sculptors': {'type': 'uri', 'value': 'http://www.wikidata.org/entity/Q22338471'}, 'sculptorsLabel': {'xml:lang': 'en', 'type': 'literal', 'value': 'Anna Palm'}, 'sculptorsDescription': {'xml:lang': 'en', 'type': 'literal', 'value': 'Swedish sculptress'}, 'died': {'type': 'literal', 'value': '1963-08-14'}, 'birth': {'type': 'literal', 'value': '1881-07-14'}, 'WD': {'type': 'literal', 'value': 'Q22338471'}}
{'sculptors': {'type': 'uri', 'value': 'http://www.wikidata.org/entity/Q23989419'}, 'sculptorsLabel': {'xml:lang': 'en', 'type': 'literal', 'value': 'Bess Wissler'}, 'sculptorsDescription': {'xml:lang': 'en', 'type': 'literal', 'value': 'Swedish sculptress'}, 'died': {'type': 'literal', 'value': '1952-07-10'}, 'birth': {'type': 'literal', 'value': '1866-12-27'}, 'WD': {'type': 'literal', 'value': 'Q23989419'}}
{'sculptors': {'type': 'uri', 'value': 'http://www.wikidata.org/entity/Q23989466'}, 'sculptorsLabel': {'xml:lang': 'en', 'type': 'literal', 'value': 'Carin Nilson'}, 'sculptorsDescription': {'xml:lang': 'en', 'type': 'literal', 'value': 'Swedish sculptress'}, 'died': {'type': 'literal', 'value': '1973-06-20'}, 'birth': {'type': 'literal', 'value': '1884-09-13'}, 'WD': {'type': 'literal', 'value': 'Q23989466'}}
{'sculptors': {'type': 'uri', 'value': 'http://www.wikidata.org/entity/Q23989466'}, 'sculptorsLabel': {'xml:lang': 'en', 'type': 'literal', 'value': 'Carin Nilson'}, 'sculptorsDescription': {'xml:lang': 'en', 'type': 'literal', 'value': 'Swedish sculptress'}, 'died': {'type': 'literal', 'value': '1973-06-20'}, 'birth': {'type': 'literal', 'value': '1884-09-13'}, 'WD': {'type': 'literal', 'value': 'Q23989466'}}
{'sculptors': {'type': 'uri', 'value': 'http://www.wikidata.org/entity/Q23989466'}, 'sculptorsLabel': {'xml:lang': 'en', 'type': 'literal', 'value': 'Carin Nilson'}, 'sculptorsDescription': {'xml:lang': 'en', 'type': 'literal', 'value': 'Swedish sculptress'}, 'died': {'type': 'literal', 'value': '1973-06-20'}, 'birth': {'type': 'literal', 'value': '1884-09-13'}, 'WD': {'type': 'literal', 'value': 'Q23989466'}}
{'sculptors': {'type': 'uri', 'value': 'http://www.wikidata.org/entity/Q23989466'}, 'sculptorsLabel': {'xml:lang': 'en', 'type': 'literal', 'value': 'Carin Nilson'}, 'sculptorsDescription': {'xml:lang': 'en', 'type': 'literal', 'value': 'Swedish sculptress'}, 'died': {'type': 'literal', 'value': '1973-06-20'}, 'birth': {'type': 'literal', 'value': '1884-09-13'}, 'WD': {'type': 'literal', 'value': 'Q23989466'}}
{'sculptors': {'type': 'uri', 'value': 'http://www.wikidata.org/entity/Q27902203'}, 'sculptorsLabel': {'xml:lang': 'en', 'type': 'literal', 'value': 'Anna Kallstenius'}, 'sculptorsDescription': {'xml:lang': 'en', 'type': 'literal', 'value': 'Swedish sculptress'}, 'died': {'type': 'literal', 'value': '1966-09-23'}, 'birth': {'type': 'literal', 'value': '1872-07-08'}, 'WD': {'type': 'literal', 'value': 'Q27902203'}}
{'sculptors': {'type': 'uri', 'value': 'http://www.wikidata.org/entity/Q48704874'}, 'sculptorsLabel': {'xml:lang': 'en', 'type': 'literal', 'value': 'Anna Troili-Petersson'}, 'sculptorsDescription': {'xml:lang': 'en', 'type': 'literal', 'value': 'Swedish sculptress'}, 'died': {'type': 'literal', 'value': '1934-05-04'}, 'birth': {'type': 'literal', 'value': '1875-07-31'}, 'WD': {'type': 'literal', 'value': 'Q48704874'}}
Process finished with exit code 0