Skip to content

Instantly share code, notes, and snippets.

@henhuy
Created April 15, 2024 09:13
Show Gist options
  • Save henhuy/4d6fcdf9c08466cd989830eb5f01d717 to your computer and use it in GitHub Desktop.
Save henhuy/4d6fcdf9c08466cd989830eb5f01d717 to your computer and use it in GitHub Desktop.
SPARQL databus collection files
from SPARQLWrapper import JSON, SPARQLWrapper2
DATABUS_ENDPOINT = "https://databus.openenergyplatform.org/sparql"
query = """
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX dcat: <http://www.w3.org/ns/dcat#>
PREFIX dct: <http://purl.org/dc/terms/>
PREFIX dcv: <https://dataid.dbpedia.org/databus-cv#>
PREFIX databus: <https://dataid.dbpedia.org/databus#>
SELECT ?file WHERE
{
{
GRAPH ?g
{
{
?dataset databus:group <https://databus.openenergyplatform.org/felixmaur/sedos_template> .
{
?dataset databus:artifact <https://databus.openenergyplatform.org/felixmaur/sedos_template/x2x_import_coke_oven_gas> .
}
UNION
{
?dataset databus:artifact <https://databus.openenergyplatform.org/felixmaur/sedos_template/x2x_import_elec> .
}
UNION
{
?dataset databus:artifact <https://databus.openenergyplatform.org/felixmaur/sedos_template/x2x_import_h2> .
}
UNION
{
?dataset databus:artifact <https://databus.openenergyplatform.org/felixmaur/sedos_template/x2x_import_natural_gas> .
}
UNION
{
?dataset databus:artifact <https://databus.openenergyplatform.org/felixmaur/sedos_template/excess_n2o> .
}
UNION
{
?dataset databus:artifact <https://databus.openenergyplatform.org/felixmaur/sedos_template/excess_ch4> .
}
UNION
{
?dataset databus:artifact <https://databus.openenergyplatform.org/felixmaur/sedos_template/excess_co2> .
}
UNION
{
?dataset databus:artifact <https://databus.openenergyplatform.org/felixmaur/sedos_template/ind_test_steel_demand> .
}
}
UNION
{
?dataset databus:group <https://databus.openenergyplatform.org/anik/Industry_test> .
{
?dataset databus:artifact <https://databus.openenergyplatform.org/anik/Industry_test/ind_steel_casting_0> .
}
UNION
{
?dataset databus:artifact <https://databus.openenergyplatform.org/anik/Industry_test/ind_steel_casting_1> .
}
UNION
{
?dataset databus:artifact <https://databus.openenergyplatform.org/anik/Industry_test/ind_steel_hyddri_1> .
}
UNION
{
?dataset databus:artifact <https://databus.openenergyplatform.org/anik/Industry_test/ind_steel_boiler_0> .
}
UNION
{
?dataset databus:artifact <https://databus.openenergyplatform.org/anik/Industry_test/ind_scalars> .
}
UNION
{
?dataset databus:artifact <https://databus.openenergyplatform.org/anik/Industry_test/ind_timeseries> .
}
}
UNION
{
?dataset databus:group <https://databus.openenergyplatform.org/felixmaur/global_emissions> .
{
?dataset databus:artifact <https://databus.openenergyplatform.org/felixmaur/global_emissions/global_emission_factors> .
}
}
?dataset dcat:distribution ?distribution .
?distribution databus:file ?file .
}
}
}
"""
sparql = SPARQLWrapper2(DATABUS_ENDPOINT)
sparql.setReturnFormat(JSON)
sparql.setQuery(query)
data = sparql.query()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment