2007-01-16 04:21:33 +01:00
[[meta title="table (third-party plugin)"]]
2007-02-09 04:16:09 +01:00
This plugin supplies a `table` [[PreprocessorDirective]] to build html tables from data in CSV (comma-separated values) or DSV (delimiter-separated values) format.
2007-01-15 11:14:28 +01:00
2007-02-09 04:16:09 +01:00
It needs the perl module [[cpan Text::CSV]] for the CSV data.
2007-01-15 11:14:28 +01:00
2007-02-09 04:16:09 +01:00
## Usage
2007-01-15 11:14:28 +01:00
In any source page include the following:
2007-02-09 04:16:09 +01:00
The next table shows the results:
2007-01-15 11:14:28 +01:00
\[[table class="myclass" format=dsv data="""
Custom|Amount|
Fulanito|134,34|
Menganito|234,56|
"""]]
This is my last acquisition:
[[table class="book_record" format=csv file="data/books/record1"]]
And the record1 page should be similar to:
"Title","Perl Best Practices"
"Author","Damian Conway"
"Publisher","O’ Reilly"
The parameters are:
2007-02-09 04:16:09 +01:00
- _data_: Values for the table
- _file_: Wiki page containing the data.
2007-01-15 12:35:25 +01:00
- _format_ (optional): format name of the data. By default is `auto` and the options are `csv` or `dsv`.
2007-02-09 04:16:09 +01:00
- _delimiter_ (optional): The character used to separate fields. By default, DSV format uses a pipe (`|`), and CSV uses a comma (`,`).
- _class_ (optional): CSS class for the table html element
- _caption_ (optional): Text string for the table caption.
- _no\_header_: This switch disables the generation of table header (`<th>`) elements. By default, the `table` directive uses the first data line as column headers.
2007-01-15 11:14:28 +01:00
2007-02-09 04:16:09 +01:00
The _data_ and _file_ parameters are mutually exclusive.
2007-01-15 11:14:28 +01:00
2007-02-09 04:16:09 +01:00
Note: the automatic format detection mechanism is still very rudimentary.
2007-01-15 12:35:25 +01:00
## Changelog
### version 0.5
2007-02-09 04:16:09 +01:00
* Remove a call to an inexistent [[cpan Text::CSV]] method.
2007-01-15 12:35:25 +01:00
* Added the sep_char parameter.
2007-02-09 04:16:09 +01:00
* Parse CSV data in binary mode.
2007-01-15 12:35:25 +01:00
* Added a format detection mechanism.
* Default format now is 'auto'.
2007-01-15 11:14:28 +01:00
## Links
- Information about the formats in Wikipedia:
- [[wikipedia CSV]]
- [[wikipedia DSV]]
2007-02-09 04:16:09 +01:00
- Download the tar file from <http://taquiones.net/files/misc/>
2007-01-15 11:14:28 +01:00
- Debian package in <http://taquiones.net/files/debian/>