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
- Format specific
⧼validator-describe-header-parameter⧽ | ⧼validator-describe-header-type⧽ | ⧼validator-describe-header-default⧽ | ⧼validator-describe-header-description⧽ |
---|---|---|---|
sep | ⧼validator-type-string⧽ | , | Specifies a column separator |
valuesep | ⧼validator-type-string⧽ | , | Specifies a value separator |
showsep | ⧼validator-type-boolean⧽ | no | Show separator in top of CSV file ("sep=<value>") |
filename | ⧼validator-type-string⧽ | result.csv | The name for the output file |
merge | ⧼validator-type-boolean⧽ | no | Merge rows and column values with an identical subject identifier (aka first column) |
bom | ⧼validator-type-boolean⧽ | no | Add a BOM (character to signal endianness) at the top of the output file |
valuesep
"3, "merge
"45 and "bom
"6 parameters.
Remarks
- 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
Default
- Syntax
{{#ask: [[Category:City]] [[Located in::Germany]] |?Population |?Area#km²=Area |mainlabel=City |format=csv }}
- Result
Change file name
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
Between results
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
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
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
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
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