...
1let
2 GetLabel = (subject as text) as nullable table =>
3 let
4 // Request Ntriples from the LDF Service
5 Options = [Headers = [#"Accept"="text/csv"]],
6 FixedSubject = if Text.At(subject,0) <> "<" then Text.Combine({"<",subject,">"}) else subject,
7 Query = Text.Combine({"SELECT ?label WHERE {
8 SERVICE wikibase:label {
9 bd:serviceParam wikibase:language ""en"" .
10 ",FixedSubject," <http://www.w3.org/2000/01/rdf-schema#label> ?label
11 }
12 }"}),
13 /* this is a multiline comment, see https://docs.microsoft.com/en-us/powerquery-m/comments
14 */
15 url = Text.Combine({"https://query.wikidata.org/sparql?",Uri.BuildQueryString([query=Query])}),
16 data = Csv.Document(Web.Contents(url,Options)),
17 promoted = Table.PromoteHeaders(data, [PromoteAllScalars=true])
18 in
19 promoted
20in
21 GetLabel
View as plain text