DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:csvtodwpages

CSV to DW Pages Exploder Plugin

Compatible with DokuWiki

  • 2025-05-14 "Librarian" yes
  • 2024-02-06 "Kaos" yes
  • 2023-04-04 "Jack Jackrum" yes
  • 2022-07-31 "Igor" yes

plugin Allows managers to explode csv files into multiple DokuWiki pages

Last updated on
2025-05-19
Provides
Admin

Tagged with csv, exploder

Installation

Search and install the plugin using the Extension Manager. Refer to Plugins on how to install plugins manually.

Where To Find It

After installation, you will find the link to the pugin on your Admin page under Additional Plugins

harpanet.com_csvtodwpages_v01_where_to_find_it.jpg

Examples/Usage

Using the demo data (see below) you will generate an index page and multiple content pages exploded from the csv data.

Autogenerated Index Page

harpanet.com_csvtodwpages_v01a_demo_index_01a.jpg

Exploded Content Page

harpanet.com_csvtodwpages_v01a_demo_page_01a.jpg

Configuration and Settings

All fields are required.

harpanet.com_csvtodwpages_v01_csvtodwpages_01.jpg

Namespace: this is the namespace into which the exploded pages are going to be created.

CSV columns for pagenames: The exploded page name will be generated from one (or more) of the columns in the csv file. Enter a number (or comma separated list of numbers) representing the column in the csv file containing the unique page name. This can be a single value (eg. 0 - to take the name from the first column) or a list (eg. 3,5 - to build a page name from the combination of data in the 4th and 6th column). When a list is given, the page name separates each column using an underscore '_' (eg. youngstown_oh).

CSV Delimiter: For the basic processing of this plugin it should always be a comma here, but you have the option to change the character that separates each column field if necessary.

Page Template: This is the content from a standard dokuwiki page, using placeholders inside square brackets to represent where csv data is to be injected. eg. The City: [city] - Note that all placeholders MUST be written in lowercase (regardless of the column name in the csv file).

CSV Data File: Paste your csv file into this text area. The first row of the csv data MUST contain the column names.

Overwrite Page? Setting this to YES will overwrite (without further confirmation) any existing pages with the same name in the specified namespace.

Dummy Run? Setting this to YES will perform the explosion without creating any files. Always worth doing a dummy run to test your template and csv file before running it live. If you choose a dummy run, you will also be shown an example of a populated template page so that you can check that the [placeholders] are doing what you expect. The data in the example will be taken from the last row of the csv file.

Trim spaces? Setting this to YES (probably used 99.99% of the time) will, erm, strip spaces from the exploded csv data before it is injected into the [placeholder].

A Dummy Run

A dummy run produces no files/pages, it just indicates what will happen.

harpanet.com_csvtodwpages_v01_dummyrun_01.jpg harpanet.com_csvtodwpages_v01_examplepage_01.jpg

Note the last line, which provides a link to an auto-generated index page containing links to all the exploded pages.

Demo Data

To test results on your system you can use the following template and csv data. For this csv data, specify columns '8,9' as the pagename combo.

The Demo Template

====== DokuWiki Page from CSV : [city]_[state] ======

The City: [city]

The State: [state]

Their Position: [latd], [latm], [lats], [ns], [lond], [lonm], [lons], [ew]


==== end of page ====

This page has been generated from a csv exploder.

Bye.

The Demo CSV Data

"LatD", "LatM", "LatS", "NS", "LonD", "LonM", "LonS", "EW", "City", "State"
   41,    5,   59, "N",     80,   39,    0, "W", "Youngstown", OH
   42,   52,   48, "N",     97,   23,   23, "W", "Yankton", SD
   46,   35,   59, "N",    120,   30,   36, "W", "Yakima", WA
   42,   16,   12, "N",     71,   48,    0, "W", "Worcester", MA
   43,   37,   48, "N",     89,   46,   11, "W", "Wisconsin Dells", WI
   36,    5,   59, "N",     80,   15,    0, "W", "Winston-Salem", NC
   49,   52,   48, "N",     97,    9,    0, "W", "Winnipeg", MB
   39,   11,   23, "N",     78,    9,   36, "W", "Winchester", VA
   34,   14,   24, "N",     77,   55,   11, "W", "Wilmington", NC
   39,   45,    0, "N",     75,   33,    0, "W", "Wilmington", DE
   48,    9,    0, "N",    103,   37,   12, "W", "Williston", ND
   41,   15,    0, "N",     77,    0,    0, "W", "Williamsport", PA
   37,   40,   48, "N",     82,   16,   47, "W", "Williamson", WV
   33,   54,    0, "N",     98,   29,   23, "W", "Wichita Falls", TX
   37,   41,   23, "N",     97,   20,   23, "W", "Wichita", KS
   40,    4,   11, "N",     80,   43,   12, "W", "Wheeling", WV
   26,   43,   11, "N",     80,    3,    0, "W", "West Palm Beach", FL
   47,   25,   11, "N",    120,   19,   11, "W", "Wenatchee", WA
   41,   25,   11, "N",    122,   23,   23, "W", "Weed", CA

FAQ

Changelog

2025-MAY-19 Release v 01b

  • Updated for Librarian release
    NOTE: The Extension Manager will not show this plugin as updated as it is not stored in a repository. Clicking RE-INSTALL in Extension Manager will update it to the latest release though.

  • Fixes warning: resolve_id() is deprecated. It was called from admin_plugin_csvtodwpages::_csvexploder() in /public_html/wiki/lib/plugins/csvtodwpages/admin.php dokuwiki\File\Resolver and its children should be used instead!
  • Fixes warning: ptln() is deprecated. It was called from admin_plugin_csvtodwpages::html() in /public_html/wiki/lib/plugins/csvtodwpages/admin.php:74 echo should be used instead!
  • Fixes warning: require_once() is deprecated. It was called from require() in /public_html/wiki/lib/plugins/csvtodwpages/admin.php:6 Autoloading should be used instead!
  • Switched use of $_REQUEST to $INPUT class in admin.php as per https://www.dokuwiki.org/devel:request_vars

2024-SEP-23 Release v 01a

  • Fixes link to autogenerated index file - now uses full url to include doku.php on systems that have it
  • Fixes template for autogenerated index file in lang/en
  • Separate notices for page and index page messages in lang/en
  • Minor CSS style changes
  • Added the admin icon

2024-SEP-22 Initial Release v 01

Troubleshooting

Known Bugs and Issues

  • This is not a full-blown CSV processor. I suggest you work with relatively straightforward csv files.
  • If a page already exists within the chosen namespace within dokuwiki but it cannot be overwritten for some unforseen reason (permissions changed, etc.) then the exploded file log with say it has been created (checked using a page_exists() method), however a dokuwiki notification will be generated to show an error occurred. In this instance, the page from the csv data will not have been generated. harpanet.com_csvtodwpages_v01_not_created_01.jpg
plugin/csvtodwpages.txt · Last modified: by 103.69.224.20

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