Moduuli:Tabular data/ohje

Wikipediasta
Siirry navigaatioon Siirry hakuun

This module provides basic functions for interacting with tabular data on Wikimedia Commons.

Returns the value of the cell at the given row index and column name.

Usage: {{#invoke:Tabular data|cell|Page name.tab|output_row=Index of row to output|output_column=Name of column to output}}

A row index of 1 refers to the first row in the table. A row index of -1 refers to the last row in the table. It is an error to specify a row index of 0.

Latest death toll in c:Data:COVID-19 cases in Santa Clara County, California.tab (regardless of when the table was last updated):

{{#invoke:Tabular data|cell
|output_row=-1
|output_column=deaths
|COVID-19 cases in Santa Clara County, California.tab}}

3221

Returns the value of the cell(s) in one or more output columns of the row matching the search key and column.

This function is reminiscent of LOOKUP() macros in popular spreadsheet applications, except that the search key must match exactly. (On the other hand, this means the table does not need to be sorted.)

Usage: {{#invoke:Tabular data|lookup|Page name.tab|search_value=Value to find in column|search_column=Name of column to search in|output_column=Name of column to output|output_column2=Name of another column to output|output_columnn=…|output_format=[mw:Extension:Scribunto/Lua reference manual#string.format|String format]] to format the output}}

If multiple columns are output without an explicit string format, this function formats the output as a human-readable list.

Some may find {{Tabular query}} (which uses this module) an intuitive way to obtain cell data as it resembles a simple SQL query.

|1=
Page name on Commons with extension but no namespace
|search_value= or |search_pattern=
Value to find or pattern to match in column
|search_column=
Name of column to search in
|occurrence=
Index of the match to output in case of multiple matching rows. A row index of 1 refers to the first matching row. A row index of -1 refers to the last matching row. It is an error to specify a row index of 0.
|output_column= or |output_column1=, |output_column2=, ...
Names of columns to output
|output_format=
String format to format the output

Total confirmed case count in c:Data:COVID-19 cases in Santa Clara County, California.tab on the day that the county issued a stay-at-home order:

Lua-virhe kohdassa Moduuli:Tabular_data rivillä 48: Output column “totalConfirmedCases” not found..

The last day that a hundred or more patients with COVID-19 were in the hospital in c:Data:COVID-19 cases in Solano County, California.tab:

{{#invoke:Tabular data|lookup
|search_pattern=%d%d%d
|search_column=hospitalized
|output_column=date
|occurrence=-1
|COVID-19 cases in Solano County, California.tab}}

2022-02-06

Total number of administrators on all Wikimedia wikis using c:Data:Wikipedia statistics/data.tab:

{{#invoke:Tabular data|lookup
|search_column=site
|search_value=total.all
|output_column=admins
|Wikipedia statistics/data.tab}}

5640

Number of administrators and users on all Wikimedia wikis using c:Data:Wikipedia statistics/data.tab:

{{#invoke:Tabular data|lookup
|output_column=admins
|output_format=%d out of %d users are administrators
|search_column=site
|output_column2=users
|search_value=total.all
|Wikipedia statistics/data.tab}}

5640 out of 215558358 users are administrators

Note: Wikipedia statistics are shown as an illustration only. In practice, there is a high-performance module {{NUMBEROF}} to access Wikipedia statistics.

Returns the entire data table as a (rather plain) table.

Usage: {{#invoke:Tabular data|wikitable|Page name.tab}}

Tämä on ohjesivu moduulille Moduuli:Tabular data