Status: | effective |
Progress: | 100% |
Version: | 3.0.0+ |
Help:CSV format
CSV format | |
---|---|
Outputs results in Windows-style Comma Separated Value format. | |
Further Information | |
Provided by: | Semantic MediaWiki |
Added: | 1.2.1 |
Removed: | still supported |
Requirements: | none |
Format name: | csv |
Enabled? Indicates whether the result format is enabled by default upon installation of the respective extension. | yes |
Authors: | Nathan Yergler , Markus Krötzsch , James Hong Kong |
Categories: | export · plaintext |
Table of Contents | |
The result format csv is used to produce links to CSV files which allow to export the result of a query. See also result format "DSV"Outputs results in *NIX-style Delimiter Separated Value format. with is similar to this one.
Parameters[edit]
- Format specific
Parameter | Type | Default | Description |
---|---|---|---|
sep | text | , | Specifies a column separator |
valuesep | text | , | Specifies a value separator |
showsep | yes/no | no | Show separator in top of CSV file ("sep=<value>") |
filename | text | result.csv | The name for the output file |
merge | yes/no | no | Merge rows and column values with an identical subject identifier (aka first column) |
bom | yes/no | no | Add a BOM (character to signal endianness) at the top of the output file |
valuesep
"3, "merge
"45 and "bom
"6 parameters.
Remarks[edit]
- All numeric or named entities in the generated output are decoded as UTF-8 strings. Therefore the character set in your application has to be set accordingly (UTF-8).
- On most platforms, CSV files will be automatically opened by the default application for using spreadsheets.
Examples[edit]
Default[edit]
- Syntax
{{#ask: [[Category:City]] [[Located in::Germany]] |?Population |?Area#km²=Area |mainlabel=City |format=csv }}
- Result
Change file name[edit]
Another file name for exporting the results can be specified by changing the filename
parameter:
- Syntax
{{#ask: [[Category:City]] [[Located in::Germany]] |?Population |?Area#km²=Area |mainlabel=City |format=csv |filename=example.csv }}
- Result
Change separators[edit]
Between results[edit]
Another separator between results than "," e.g. ";" can be used if specified by the sep
parameter:
- Syntax
{{#ask: [[Category:City]] [[Located in::Germany]] |?Population |?Area#km²=Area |mainlabel=City |format=csv |sep=; }}
- Result
Between property values[edit]
Another separator between results than "," e.g. "~" can be used if specified by the valuesep
parameter:
- Syntax
{{#ask: [[Category:City]] [[Located in::Germany]] |?Population |?Area#km²=Area |?Has zoo=Zoo |mainlabel=City |format=csv |valuesep=~ }}
- Result
Output separator used[edit]
The separator used between results can be listed too in the exported file by setting the showsep
parameter to yes
:
- Syntax
{{#ask: [[Category:City]] [[Located in::Germany]] |?Population |?Area#km²=Area |?Has zoo=Zoo |mainlabel=City |format=csv |showsep=yes }}
- Result
Combine results for identical subject identifiers[edit]
Subject identifier with identical row and column values can be merged by setting the merge
parameter to yes
, e.g. lines containing "Foo", "1", "2", "3" and "Foo", "4", "5", "6" will result in "Foo", "1,4", "2,5", "3,6".5. Such a situation can normally only appear when mainlabel=-
is used that creates a specific first column and contains identical identifier.
Add the byte order mark[edit]
The byte order mark (BOM) can be added to the exported file by setting the bom
parameter to yes
:
- Syntax
{{#ask: [[Category:City]] [[Located in::Germany]] |?Population |?Area#km²=Area |?Has zoo=Zoo |mainlabel=City |format=csv |bom=yes }}
- Result
References
- ^ Semantic MediaWiki: GitHub pull request gh:smw:2420
- ^ Semantic MediaWiki: GitHub pull request gh:smw:2718
- ^ Semantic MediaWiki: GitHub pull request gh:smw:2826
- ^ Semantic MediaWiki: GitHub pull request gh:smw:2822
- a b Semantic MediaWiki: Sandbox example sb:smw:2822
- ^ Semantic MediaWiki: GitHub pull request gh:smw:2824