This is an old revision of the document!
Table of Contents
Compatible with DokuWiki
- 2022-07-31 "Igor" unknown
- 2020-07-29 "Hogfather" yes
- 2018-04-22 "Greebo" yes
- 2017-02-19 "Frusterick Manners" unknown
This plugin was originally written by Steven Danz. The current version fixes security bugs and incorporates several patches by other contributors.
- »2017-02-19 “Frusterick Manners”« - plugin version 2022-01-03
- Not working on: Synology NAS running DSM 5 / PHP 5.5.3 —JoeT 2022-07-15
- Not observed with »2018-04-22a “Greebo”« (also Info plugin v. 2014-10-01) running on a virtual machine. ⇒ perhaps a PHP version incompatibility
This is a simple plugin that will display CSV data in table form. The data can either be inline between
<csv> Number,Name,Details 1,Power Man,Blue 2,Red Book,"Yellow, but blue" </csv>
or be read from a file in the media area using
You can also give an HTTP URL to a CSV file instead of an uploaded media file.
If you are planning to use csv files in the media area, you will most likely need to include the .csv file extension in mime.local.conf so you can upload .csv files. Something like this should get you started:
<csv> tag allows for additional options to be specified as well as a file reference.
| || where ||
| ||Format the first <n> rows of data from the CSV as column headers||
| ||Format the first <n> columns of each row as column headers||
| ||Create colspans for each empty (two adjacent commas) cell following a cell with content||
| || The delimiter used between cells. Specify ||
| ||limiting the result set to a certain number of rows||
| ||skipping the given number of rows before output||
| || Allows you to filter the rows. <n> is the column number you want to filter on. The first column is 1. t can either be an |
Cells that include a comma as part of the data are expected to be contained between double quotes, which is the typical behaviour of most systems when exporting .csv files.
Empty lines in the csv file or data are displayed as horizontal separators in the table.
Example for a table using a filter. This will look for values beginning with “P” in the third column. It will show the second line.
<csv hdr_rows=0 filter[g]="P*"> ABC,DEF,GHI JKL,MNO,PQR </csv>
There is a second syntax mode to grab a single value from a CSV. This mode does not support inline CSV data!
<csvval some.csv output=3,1>
In addition to all the options supported in the
<csv> syntax, you have to specify which column and (optionally) which row you want to output.
- Version upped (2022-01-03 23:50)
- code style cleanup (2022-01-03 16:51)
- test cleanup and PHP8 fixes (2022-01-03 16:41)
- wrap contents in thead and tbody tags (2021-11-12 03:08)
- Version upped (2021-02-18 23:50)
- Merge pull request #21 from alex-krippner/issue_plugin-csv-#19 (2021-02-18 16:53)
- edited error message #19 (2021-02-18 14:39)
- added error message when no filter results (2021-02-17 13:47)
- is it possible to add a download-button so that the csv-file could be directly downloaded (especially for inline-data)
- might be nice to be able to have gridlines
Is it possible to put internal DokuWiki links in table cells to make them clickable?see Issue #10 External links within table cellssee Issue #10
- Selection of rows and columns would be great e.g. rows=1,5,6,7 Issue #1
- Setting of column width would be great
- Justify right/align right
- Integration with the bootstrap theme → header is not in the right colour. Global style of the table looks different than if you use the default syntax.
Use of smileys (for example traffic light based on values)see Issue #10
- read data from a csv-file stored at Windows Shares like windows_shares
- Add row/column header via parameter
- Make table sortable by different columns
Use with a Google Docs Spreadsheet
The HTTP URL can be a shared Google Docs Spreadsheet. The following explains how to export a spreadsheet in CSV format via a URL.
To link to a Google spreadsheet:
- Open your spreadsheet in Google Docs.
- Click the “Share” botton in the toolbar, and choose “Anyone with the link” for Visibility.
- Open your spreadsheet in Google Docs.
- From the spreadsheet menu select: File | Publish as a Web Page
- Sheets to Publish: “All Sheets”, and check the box “Automatically republish when changes are made” to ensure your data is auto updated.
- Click “Start Publishing”. This will activate the options in the box “Get a link to the published data”, below.
- Change the export type from “Web Page” to “CSV (comma-separated values)”.
- Change “All sheets” to “Sheet1” (or select the sheet you want to export)
- Change “All Cells” to the specific range you want to export, beginning with the header row. Use Excel-style notation, like “A1:C6” for the first 3 columns and the first 6 rows.
- Click “Republish now”
- Copy the link (check it ends with output=csv) and paste it into your dokuwiki CSV table using the file= attribute described above.
Outline of steps adapted from: