Last active
March 5, 2017 02:06
-
-
Save boaarmpit/1c91d7c7849090e31307a701ae66abd4 to your computer and use it in GitHub Desktop.
Example using the open data provided by Osaka city
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
# Setup environment using 'source setup.sh' | |
# then run with 'python testosaka.py' | |
# (tested with blank c9.io workspace) | |
from SPARQLWrapper import SPARQLWrapper, JSON | |
sparql = SPARQLWrapper("https://data.city.osaka.lg.jp/sparql") | |
sparql.setQuery(""" | |
PREFIX ic: <http://imi.ipa.go.jp/ns/core/rdf#> | |
PREFIX dsv: <http://datashelf.jp/ns/dsv#> | |
select distinct ?s ?label ?address ?lat ?long where { | |
?s a ic:施設型 ; | |
rdfs:label ?label ; | |
ic:住所 / ic:表記 ?address ; | |
ic:種別 "防災関連施設 - 災害時用へリポート" ; | |
ic:地理座標 / ic:緯度 ?lat ; | |
ic:地理座標 / ic:緯度 ?long . | |
} LIMIT 100 | |
""") | |
sparql.setReturnFormat(JSON) | |
results = sparql.query().convert() | |
for result in results["results"]["bindings"]: | |
print(result["label"]["value"]) |
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
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda.sh | |
bash ~/miniconda.sh -b -p $HOME/miniconda | |
echo 'export PATH="$HOME/miniconda/bin:$PATH"' >> ~/.bashrc | |
source ~/.bashrc | |
conda create -y -n py3 python=3 | |
source activate py3 | |
conda install -y Flask | |
pip install sparqlwrapper |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment