Difference between revisions of "ImportCSV"

From Organic Design wiki
m (See also)
(Change source-code blocks to standard format)
 
Line 2: Line 2:
  
 
Each line in the files is a list of text fields separated by a '''tab''' character. The first line of the file is taken to be the names of the fields. Following is an example of some typical input data:
 
Each line in the files is a list of text fields separated by a '''tab''' character. The first line of the file is taken to be the names of the fields. Following is an example of some typical input data:
{{code|<pre>
+
<source>
 
Title FirstName Initial Surname
 
Title FirstName Initial Surname
 
Mr. Bob G. McFoo
 
Mr. Bob G. McFoo
Line 9: Line 9:
 
Dr. John Bizman
 
Dr. John Bizman
 
Miss Mary B. Buzby
 
Miss Mary B. Buzby
</pre>}}
+
</source>
  
  
 
The import procedure creates (or edits if it all ready exists) an article for each roe of the input file. For example the first row of the example input above may become an article called '''Mr. Bob G. McFoo''' and contain the following:
 
The import procedure creates (or edits if it all ready exists) an article for each roe of the input file. For example the first row of the example input above may become an article called '''Mr. Bob G. McFoo''' and contain the following:
{{code|<pre>
+
<source>
 
{{Person
 
{{Person
 
  | Title    = Mr.
 
  | Title    = Mr.
Line 20: Line 20:
 
  | Surname  = McFoo
 
  | Surname  = McFoo
 
}}
 
}}
</pre>}}
+
</source>
  
  

Latest revision as of 18:11, 22 May 2015

The ImportCSV job-type is a generic job for importing CSV text files into wiki articles. It consists of the ImportCSV.pl Perl script to be required in /var/www/tools/wikid.conf, and the ImportCSV.php script which must be included in the wikis LocalSettings.php.

Each line in the files is a list of text fields separated by a tab character. The first line of the file is taken to be the names of the fields. Following is an example of some typical input data:

Title	FirstName	Initial	Surname
Mr.	Bob		G.	McFoo
Mrs.	Sally		H.	Barson
Mr.	Joe			Bazberg
Dr.	John			Bizman
Miss	Mary		B.	Buzby


The import procedure creates (or edits if it all ready exists) an article for each roe of the input file. For example the first row of the example input above may become an article called Mr. Bob G. McFoo and contain the following:

{{Person
 | Title     = Mr.
 | FirstName = Bob
 | Initial   = G.
 | Surname   = McFoo
}}


A few parameters need to be supplied to the ImportCSV job such as the source filename, the template to use (in this case "Person") and which fields to construct the article title from (In this case all four fields in order separated by spaces). Here is a screenshot of the form filled in to give the format shown above, note that the title format parameter can reference the columns either numerically, by name, or both.

ImportCSVForm.jpg

  • Note1 If the title format parameter is left empty, the article title will be a GUID
  • Note2 multiple spaces are converted to single spaces in case any of the fields such as initial are empty
  • Note3 named field references are case-insensitive

See also