Search code examples
sparqldbpedia

Sparql in combination with DBpedia


i want to display the countries with their net value/income or something similiar through accessing the data through DBPedia. and further insert them into an already created table. Unfortunately i dont get any results with my code. Screenshot of SPARQL query and result


Solution

  • Try the following query to list the type of entities that has a dbp:income as a property. you will notice that dbo:Country is not the list, that's why the result you got was empty.

    prefix dbp:  <http://dbpedia.org/property/>
    select distinct  ?type
    where {
        ?s a ?type.
        ?s dbp:income ?income
    }
    

    My suggestion is to use dbp:gdpNominal instead of the dbp:income property in your query :

    prefix dbp:  <http://dbpedia.org/property/>
    prefix dbo: <http://dbpedia.org/ontology/>
    
    select distinct  ?country_name ?income
    where {
        ?country a dbo:Country. 
        ?country rdfs:label ?country_name.  FILTER (lang(?country_name) = 'en')  
        ?country  dbp:gdpNominal ?income.
    }