Populating a mediawiki from tabular data

From Squirrel's Lair

  • Cargo:

  • Categories:
  • Default form

When you first set up a new Mediawiki it is a good idea to populate it with some starting content that uses templates. Sometimes data that needs to go on the wiki is available in tabular form. For example, you may have a spreadsheet to track tools and you want to add this to the wiki.

To make best use of the wiki you will want one page per tool, so you can add all the structured data you want, but also add as much free text as you want. This means you need to add one page per line of spreadsheet, and there could be hundreds of lines.

In this scenario I will often create a new column and use excel functions to generate text of the same format as the XML files generated by an export from Mediawiki. This file can then be imported into the wiki.

Mediawiki import/export files are of the following basic XML structure:

     <text xml:space="preserve">	the content of my page	
     </text><comment>Imported content</comment>    

So, the xml for one page can be created by putting a adding a first, third and fifth column with the xml tags.

<page><title> the title </title><revision><text xml:space="preserve"> page content </text><comment>Imported content</comment></revision></page>

The title and the page content can then be generated via excel formula from other columns if needed.

These lines are pasted into a text file, between the <mediawiki> and </mediawiki> tags. That file can then be imported to the wiki via Special Pages, Import pages. A bug on that page means that you have to enter some text into the "interwiki prefix" line or nothing will be imported.

There are additional xml tags that can be used, to see more example content export a few pages from a wiki and review the XML for examples.