Technical Overview: Form Storage -- CSV: Difference between revisions

From IHRIS Wiki
(Created page with 'This is a form storage mechanism designed to read data from a CSV file. It is primarily designed to import data. ==Form Storage Options== The options specifying a CSV storage …')
 
Line 1: Line 1:
This is a form storage mechanism designed to read data from a CSV file.  It is primarily designed to import data.
This is a form storage mechanism designed to read data from a CSV file.  It is primarily designed to import data.
This is a read-only form storage mechansim.  By default it will read in the CSV dump of a ''hippo_XXX''.


==Form Storage Options==
==Form Storage Options==
Line 7: Line 9:
It has the following structure:
It has the following structure:


*file:  The CSV file that the data should be read from.  This can either be an absolutely given file path, or a relative file path.  If it is a relative file path, then it uses the [[File Search Paths | file search]]
*file:  The CSV file that the data should be read from.  This can either be an absolutely given file path, or a relative file path.  If it is a relative file path, then it uses the CSV  [[File Search Paths | file search]] category.
*delimiter: The delimited used to split a line (one character only).  Defaults to ''',''''
*enclosure: the field enclosure character (one character only). Defaults to '''"'''
*escape: Set the escape character (one character only). Defaults as a backslash ''''\'''
*has_header:  Whether or not the first row is a header row. Defaults to true.
*has_header:  Whether or not the first row is a header row. Defaults to true.
*use_header: Defaults to true.  If true and has_header is set to true,  then the columns are referenced by the column header.  This header names are
case insensitive and ignore any white space padding.  If evaluates to false, then the columns are assumed to be numerically indexed.
*id: Optional parent node.  The data defining how to associate an id per line of this file.
**index: If set, and ''use_header'' or ''has_header'' is false, it is the numeric index of the column that this data is saved in.
**header: Applies if ''use_header'' and ''has_header'' are true.  If set it is the header name of index of the column that this data is saved in.  By default it is "id"
**form_prepended: Optional scalar node. Defaults to true. If true, it means the form name has been prepended to the id.  Otherwise, it assume that the column is just the id. 
*parent: optional parent node.  The data defining how to associate a parent id per line of this file.
**enabled: Optional scalar node.  If present and evaluates to false, it means getParent() should return the trivial parent id, '0'.
**index: If set, and ''use_header'' or ''has_header'' is false, it is the numeric index of the column that this data is saved in.
**header: Applies if ''use_header'' and ''has_header'' are true.  If set it is the header name of index of the column that this data is saved in.  By default it is "parent"
*fields: Optional parent node.  Specifies how the data of the your form is associate to a row of your table.  Each child of this node is the name of a field $field of your form.  By default, all fields of a form are populated, and are all assumed to come from the column with that field name  "$form+$field"
**enabled: Optional scalar node.  f present and evaluates to false, it means we should not populate this field.
**index: If set, and ''use_header'' or ''has_header'' is false, it is the numeric index of the column that this data is saved in.
**header: Applies if ''use_header'' and ''has_header'' are true.  If set it is the header name of index of the column that this data is saved in.  By default it is "$field"

Revision as of 11:55, 10 November 2009

This is a form storage mechanism designed to read data from a CSV file. It is primarily designed to import data.

This is a read-only form storage mechansim. By default it will read in the CSV dump of a hippo_XXX.

Form Storage Options

The options specifying a CSV storage for $form are stored at:

/modules/forms/forms/$form/storage_options/CSV

It has the following structure:

  • file: The CSV file that the data should be read from. This can either be an absolutely given file path, or a relative file path. If it is a relative file path, then it uses the CSV file search category.
  • delimiter: The delimited used to split a line (one character only). Defaults to ,'
  • enclosure: the field enclosure character (one character only). Defaults to "
  • escape: Set the escape character (one character only). Defaults as a backslash '\
  • has_header: Whether or not the first row is a header row. Defaults to true.
  • use_header: Defaults to true. If true and has_header is set to true, then the columns are referenced by the column header. This header names are

case insensitive and ignore any white space padding. If evaluates to false, then the columns are assumed to be numerically indexed.

  • id: Optional parent node. The data defining how to associate an id per line of this file.
    • index: If set, and use_header or has_header is false, it is the numeric index of the column that this data is saved in.
    • header: Applies if use_header and has_header are true. If set it is the header name of index of the column that this data is saved in. By default it is "id"
    • form_prepended: Optional scalar node. Defaults to true. If true, it means the form name has been prepended to the id. Otherwise, it assume that the column is just the id.
  • parent: optional parent node. The data defining how to associate a parent id per line of this file.
    • enabled: Optional scalar node. If present and evaluates to false, it means getParent() should return the trivial parent id, '0'.
    • index: If set, and use_header or has_header is false, it is the numeric index of the column that this data is saved in.
    • header: Applies if use_header and has_header are true. If set it is the header name of index of the column that this data is saved in. By default it is "parent"
  • fields: Optional parent node. Specifies how the data of the your form is associate to a row of your table. Each child of this node is the name of a field $field of your form. By default, all fields of a form are populated, and are all assumed to come from the column with that field name "$form+$field"
    • enabled: Optional scalar node. f present and evaluates to false, it means we should not populate this field.
    • index: If set, and use_header or has_header is false, it is the numeric index of the column that this data is saved in.
    • header: Applies if use_header and has_header are true. If set it is the header name of index of the column that this data is saved in. By default it is "$field"