DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:csv

This is an old revision of the document!


CSV Plugin

Compatible with DokuWiki

Hrun, Ponder Stibbons, Binky, Weatherwax, Adora Belle, Angua, Detritus

plugin Display CSV as table

Last updated on
2017-04-12
Provides
Syntax
Repository
Source

This extension has not been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues.

Tagged with csv, file, tables

This plugin was originally written by Steven Danz. The current version fixes security bugs and incorporates several patches by other contributors.

Description

A CosmoCode Plugin This is a simple plugin that will display CSV data in table form. The data can either be inline between <csv> and </csv>

<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

<csv namespace:test.csv></csv>

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     text/csv

The <csv> tag allows for additional options to be specified as well as a file reference.

Option Description Default value
file=<filename> where <filename> can be any <namespace:file.csv> or <http url>. The file= prefix is optional. Any option without a name is assumed to be the file name
hdr_rows=<n> Format the first <n> rows of data from the CSV as column headers 1
hdr_cols=<n> Format the first <n> columns of each row as column headers 0
span_empty_cols=[01] Create colspans for each empty (two adjacent commas) cell following a cell with content 0
delim=<char> The delimiter used between cells. Specify tab for a tab separated file. ,
maxlines=<n> limiting the result set to a certain number of rows 0
offset=<n> skipping the given number of rows before output 0
filter[<n>][t]=“<text> Allows you to filter the rows. <n> is the column number you want to filter on. t can either be an g for globbing or an r for regexp. Use simple * in the globbing mode to find partial texts.

Other options of the form <key>=<value> are possible but not used for displaying csv data yet.

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.

Download

To install this plugin manually or through the plugin manager use the following URL:

Changes

Enhancement Considerations

  • 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 cells see Issue #10
  • Other DokuWiki formatting (bold, italic, ul, Interwiki links) would be nice see 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 https://www.dokuwiki.org/wiki:syntax#windows_shares

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:

plugin/csv.1491991547.txt.gz · Last modified: 2017-04-12 12:05 by andi

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki