Welcome to the Virtual Education Wiki ~ Open Education Wiki

Help:ImportCSV

From Virtual Education Wiki
Revision as of 15:17, 24 April 2023 by Pbacsich (talk | contribs) (create new Help page)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Importing CSV files

This material is taken from https://www.mediawiki.org/wiki/Extension:Data_Transfer

For CSV import to work:

  • The file must be in standard CSV format (i.e., separated by commas, as opposed to semicolons or anything else)
  • If the file contains non-ASCII characters it must be encoded in either UTF-8 or UTF-16 (the latter being simply called "Unicode" in some Windows programs)
  • File's line breaks should contain "line feeds" ("\n") as opposed to just "carriage returns" ("\r"). This is especially if you're using Mac OS
  • The top row must contain the name of each column
    • One of the columns must contain the title of each page, and so its column name must be "Title" (in whatever language the wiki is in)
    • Another column can contain all the free, non-template text in the page: the title of this column must be "Free Text" (again, in the language of the wiki)
    • All other columns must represent the contents of a single field of a single template call; the name of such a column should be of the form "template-name[field-name]" (whitespace allowed). There is no need to separately specify the names of the template(s) called in the page.

A brief tutorial on the CSV format

If a value contains a comma, you must enclose it in double quotes. If a field containing one or more double quotes needs to be enclosed in double quotes, those double quotes should be escaped as double double quotes. An empty field can either be left empty, or contain a double double quote. You can see here for the full CSV specification.


Example

Here is an example of a CSV file that can be parsed by Data Transfer:

Title,Cheese[Country],Cheese[Texture],Free Text
Mozarella,Italy,Semi-soft,It's good on pizzas!
Cheddar,England,Hard/semi-hard,"Often sharp, but not always."
Gorgonzola,Italy,"buttery or firm, crumbly","salty, with a ""bite"" from its blue veining"
Stilton,,"",needs more data

Styles of use

Special:ImportCSV is used mainly to create sets of pages that do not already exist.

To cope with the situation where some pages already exist, there are four import options that can be set:

  • Overwrite all existing content
  • Overwrite only fields contained in the file
  • Skip
  • Append to existing content



> Help:Index