User:Thieol

From Wikidata
Jump to navigation Jump to search
Babel user information
fr-N Cet utilisateur a pour langue maternelle le français.
en-3 This user has advanced knowledge of English.
de-2 Dieser Benutzer beherrscht Deutsch auf fortgeschrittenem Niveau.
it-1 Quest'utente può contribuire con un livello elementare in italiano.
Users by language

Bot request: Wikidata:Requests for permissions/Bot

Wikidata statistics
  Number of pages 119,593,059  
  User total 6,717,927  
  Active users list 24,652  
  Administrators 73  
  Users/administrator 338  


Creating SPARQL-WIKIDATA queries in python

[edit]

For those of you who are interested in running SPARQL queries in python.

  • this is a simple program you can run :
from SPARQLWrapper import SPARQLWrapper, JSON
sparql = SPARQLWrapper("https://wdqs-beta.wmflabs.org/bigdata/namespace/wdq/sparql")
sparql.setQuery("""
    PREFIX wd: <http://www.wikidata.org/entity/>
    PREFIX wdt: <http://www.wikidata.org/prop/direct/>
    PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
    PREFIX p: <http://www.wikidata.org/prop/>
    PREFIX v: <http://www.wikidata.org/prop/statement/>
    SELECT ?p ?w ?l ?wl WHERE {
          wd:Q30 p:P6/v:P6 ?p .
          ?p wdt:P26 ?w .
          OPTIONAL  {
             ?p rdfs:label ?l FILTER (LANG(?l) = "en") .
          }
          OPTIONAL {
             ?w rdfs:label ?wl FILTER (LANG(?wl) = "en").
          }
    }""")
sparql.setReturnFormat(JSON)
results = sparql.query().convert()
for result in results["results"]["bindings"]:
    #print(result["p"]["value"]) + " " + result["w"]["value"]
    print(result["l"]["value"]) + " : " + result["wl"]["value"]
  • Enjoy !