| 16 | === On First Run === |
| 17 | In models/000_config.py their is a deployment setting to control prepopulate. This is a list of directory names and will import data from a number of CSV files. The directories must be in the private/prepopulate directory tree and must include a file called tasks.cfg. |
| 18 | |
| 19 | The tasks.cfg file comprises a list of import jobs. They can be of two distinct types: |
| 20 | * Basic Importer Jobs |
| 21 | * Special Import Jobs |
| 22 | The tasks.cfg file supports the # character on the first column as a comment. |
| 23 | ==== Basic Importer Jobs ==== |
| 24 | These will use the UI Importer to load in the data and requires the following information: |
| 25 | * The controller |
| 26 | * The function |
| 27 | * The CSV |
| 28 | * The XSL transform file |
| 29 | |
| 30 | For example: |
| 31 | {{{ |
| 32 | "survey","question_list","questionnaire24H.csv","question_list.xsl" |
| 33 | }}} |
| 34 | Which will use the questionnaire24H.csv file, which in this case will be in the same directory as the tasks.cfg file, to import the data. Using the question_list.xsl transform file which will be the static/formats/s3csv/survey directory. The importer will then use the survey/question_list function to "manage" the import using any '''onvalidate''' or '''onaccept''' callbacks that are set up by this controller. |
| 35 | |
| 36 | The CSV file does not '''need''' to be in the same directory as the tasks.cfg file, if it is held in a different file then the full path needs to be given relative to the private/prepopulate directory. |
| 37 | |
| 38 | All transform files are stored in the static/formats/s3csv directory tree. |
| 39 | ==== Special Import Jobs ==== |
| 40 | For some import jobs it is easier to create a purpose built import function rather than use the Importer. These are created by using a asterisk at the start of the line in the tasks.cfg file, as follows: |
| 41 | {{{ |
| 42 | *,gis_import_csv,USA_L1.csv |
| 43 | }}} |
| 44 | This uses the csv file '''USA_L1.csv''' and the function '''gis_import_csv''' to import, in this case, level 1 location data for the USA. |