Template:Json2table

Template documentation[view · edit · history · purge]
This documentation is transcluded from Template:Json2table/doc.
Category:Main message boxesCategory:Lua-based templates

Description

This template lets you display tabular data stored on Wikimedia Commons as a regular wiki-table. It is adapted from the former English-Wikipedia version (now deleted there and replaced by templates based on en:Module:Tabular data).

Usage

{{Json2table|dataset=...}}
  • dataset – **required**. Page name (without the “Data:” prefix) in the Commons **Data:** namespace, e.g.
 COVID-19 hospitalizations in Denmark for Data:COVID-19 hospitalizations in Denmark.tab
  • row_header – (default true) make the first column header-styled (bold).
  • col_header – (default true) use the column names as table headers.
  • caption – (default true) use the dataset’s description as the table caption.
  • empty_cell – (default “ ”) text to show when the JSON value is null.
  • columns – (default *all*) list of column keys (defined in schema.fields.name) to include, separated with “/”.
  • table_format – (default class="wikitable") extra wikitext for the opening <table> tag.
  • bare – (default false) output only the table’s rows and cells (wrap them yourself).
  • nowiki – (default false) show the table’s wikitext instead of rendering it (debugging aid).
  • lang – language code to pick the correct translation from multilingual fields; if omitted the site’s content language (English on Commons) is used.

Examples

Default

{{Json2table|dataset=Chart Example Data}} produces

Some meaningless example data about Middle-Earth for showcasing wiki charts.
Date Elves Ents Orcs Hobbits Trolls
1993/09/09 35 37 8 8 10
1993/09/14 36 33 8 10 11
1993/09/20 35 35 6 11 11
1993/09/25 30 37 8 10 13
1993/09/26 31 36 7 11 13
1993/09/26 28 34 7 12 15
1993/09/30 25 39 6 12 17
1993/10/02 26 38 8 12 14
1993/10/08 22 37 8 12 18
1993/10/16 22 40 7 13 16
1993/10/19 21 39 6 14 17
1993/10/22 18 43 7 14 18
1993/10/22 16 44 7 12 19
1993/10/25 16 41 6 13 18

Default

{{Json2table|dataset=COVID-19 hospitalizations in Denmark}} produces

Sjukhusinlagda för Covid-19 i Danmark, inklusive antal patienter i intensivvård och kritiskt tillstånd
Datum Sjukhusinlagda Patienter i intensivvård Patienter i kritiskt tillstånd Patienter i respirator Källa
11 mars 2020 10 2 https://www.tv2ostjylland.dk/tv2dk/145-i-oestjylland-og-0-paa-bornholm-saadan-er-de-smittede-fordelt-i-danmark
13 mars 2020 23 4 https://www.berlingske.dk/samfund/sundhedsministeren-23-danske-patienter-med-corona-indlagt-fire-paa
14 mars 2020 23 4 2 https://www.altinget.dk/artikel/dagens-corona-overblik-graenserne-lukkes-mens-der-bruges-penge-paa-at-udvikle-en-vaccine
15 mars 2020 28 2 https://www.dr.dk/nyheder/indland/tredje-coronarelaterede-doedsfald-i-danmark
16 mars 2020 62 10 https://www.a4nu.dk/artikel/ti-indlagt-paa-intensiv-afdeling-med-corona-i-danmark
17 mars 2020 82 18 https://ekstrabladet.dk/nyheder/samfund/18-personer-i-intensiv-behandling-for-covid-19/8051991
18 mars 2020 129 24 18 https://www.berlingske.dk/danmark/129-personer-er-indlagt-med-coronavirus-i-danmark
19 mars 2020 153 30 27 https://jyllands-posten.dk/indland/ECE12022582/nu-er-153-coronasmittede-indlagt-paa-sygehus/
20 mars 2020 186 37 32 https://files.ssi.dk/COVID19-overvaagningsrapport-20032020
21 mars 2020 206 42 35 https://jyllands-posten.dk/indland/ECE12028709/232-coronasmittede-er-indlagt-i-danmark-46-paa-intensiv/
22 mars 2020 232 46 40 https://jyllands-posten.dk/indland/ECE12028709/232-coronasmittede-er-indlagt-i-danmark-46-paa-intensiv/
23 mars 2020 254 55 47 https://jyllands-posten.dk/indland/ECE12030433/254-personer-er-indlagt-med-coronavirus-55-paa-intensiv/
24 mars 2020 301 69 58 https://files.ssi.dk/COVID19-overvaagningsrapport-24032020
25 mars 2020 350 87 76 https://jyllands-posten.dk/indland/ECE12036410/350-personer-er-nu-indlagt-med-coronavirus/
26 mars 2020 386 94 78 https://jv.dk/artikel/386-patienter-indlagt-med-coronavirus-94-p%C3%A5-intensiv
27 mars 2020 430 109 89 https://jyllands-posten.dk/indland/ECE12042212/nu-er-52-doede-med-coronavirus-i-danmark/
28 mars 2020 459 121 104 https://files.ssi.dk/COVID19-overvaagningsrapport-28032020-wl35
29 mars 2020 499 131 113 https://www.dr.dk/nyheder/indland/i-alt-77-coronasmittede-doede-i-danmark
30 mars 2020 533 137 119 https://www.dr.dk/nyheder/indland/i-alt-77-coronasmittede-doede-i-danmark
31 mars 2020 529 145 131 https://files.ssi.dk/COVID19-overvaagningsrapport-31032020-2us61
1 april 2020 535 146 129 https://files.ssi.dk/COVID19-overvaagningsrapport-01042020-apl4

Selected columns

{{Json2table|dataset=COVID-19 hospitalizations in Denmark |columns=date/hospitalizations |caption=false |row_header=false |table_format=class="wikitable sortable"}} produces

Datum Sjukhusinlagda
11 mars 2020 10
13 mars 2020 23
14 mars 2020 23
15 mars 2020 28
16 mars 2020 62
17 mars 2020 82
18 mars 2020 129
19 mars 2020 153
20 mars 2020 186
21 mars 2020 206
22 mars 2020 232
23 mars 2020 254
24 mars 2020 301
25 mars 2020 350
26 mars 2020 386
27 mars 2020 430
28 mars 2020 459
29 mars 2020 499
30 mars 2020 533
31 mars 2020 529
1 april 2020 535

See also