Skip to content

Instantly share code, notes, and snippets.

@lawlesst
Created July 31, 2013 20:40
Show Gist options
  • Save lawlesst/6125944 to your computer and use it in GitHub Desktop.
Save lawlesst/6125944 to your computer and use it in GitHub Desktop.
from vivo_utils import sparql
sparql = sparql.VIVOSparql()
sparql.login()
query = """
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX vivo: <http://vivoweb.org/ontology/core#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?geoLocation ?label
WHERE
{
?geoLocation rdf:type vivo:GeographicLocation
OPTIONAL { ?geoLocation rdfs:label ?label }
}
LIMIT 20
"""
#Optionally pass in a filename or path to save the results to CSV.
#By default results will be saved to the current directory as results.csv
sparql.results_csv(query, filename="/tmp/myresults.csv")
sparql.logout()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment