File: powerquery.actual

package info (click to toggle)
golang-github-alecthomas-chroma-v2 2.5.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 7,980 kB
  • sloc: xml: 33,149; python: 589; javascript: 357; makefile: 36; sh: 36
file content (21 lines) | stat: -rw-r--r-- 869 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
let
  GetLabel = (subject as text) as nullable table =>
    let 
      // Request Ntriples from the LDF Service
      Options = [Headers = [#"Accept"="text/csv"]],
      FixedSubject = if Text.At(subject,0) <> "<" then Text.Combine({"<",subject,">"}) else subject,
      Query = Text.Combine({"SELECT ?label WHERE {
        SERVICE wikibase:label {
        bd:serviceParam wikibase:language ""en"" .
        ",FixedSubject," <http://www.w3.org/2000/01/rdf-schema#label> ?label
        }
      }"}),
      /* this is a multiline comment, see https://docs.microsoft.com/en-us/powerquery-m/comments
      */
      url = Text.Combine({"https://query.wikidata.org/sparql?",Uri.BuildQueryString([query=Query])}),
      data = Csv.Document(Web.Contents(url,Options)),
      promoted = Table.PromoteHeaders(data, [PromoteAllScalars=true])
    in 
      promoted 
in
  GetLabel