Skip to content

Instantly share code, notes, and snippets.

@rpearl
Created March 27, 2020 18:11
Show Gist options
  • Save rpearl/ad1b9c4274207726e48fea48696925ac to your computer and use it in GitHub Desktop.
Save rpearl/ad1b9c4274207726e48fea48696925ac to your computer and use it in GitHub Desktop.
list of US shelter-in-place orders for covid-19
curl --data-urlencode query@query.sparql 'https://query.wikidata.org/sparql?format=json'
SELECT ?placeLabel ?fips ?isoStartDate ?startSource
WHERE {
?order wdt:P31 wd:Q88509703;
wdt:P1001 ?id.
FILTER(BOUND(?fips))
SERVICE wikibase:label {
bd:serviceParam wikibase:language 'en'.
?order rdfs:label ?orderLabel.
?id rdfs:label ?placeLabel.
}
OPTIONAL {
?id wdt:P882 ?fipsCounty.
}
OPTIONAL {
?id wdt:P5087 ?fipsState.
}
BIND(IF(BOUND(?fipsCounty),?fipsCounty,?fipsState) AS ?fips)
OPTIONAL {
?order wdt:P580 ?isoStartDate.
?order p:P580 ?startStatement.
?startStatement ps:P580 ?startValue.
OPTIONAL {
?startStatement prov:wasDerivedFrom ?startRefNode.
?startRefNode pr:P854 ?startURL.
}
BIND(str(?startURL) as ?startSource).
}
}
@xunhuang
Copy link

this query is awesome! I'd have to learn it some day!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment