OpenWGA 7.10 - TMLScript reference

Method :


On object AFW.Util
Usage Returns a TMLScript object to read csv data from a file or inputstream.

CSV Reader (Importer)

Config options:

  • columns: Array column definitions. Required.
  • dateFormat: Optional date format. If empty yyyy-MM-dd HH:mm:SS is used.
  • numberFormat: Optional number format. If empty # ist used.
  • skipLines: Number of lines to skip. Default = 0.
  • trimValues: Trim values (remove whitespaces before and after). Default = false
  • divider: Column divider. Default is Semicolon
  • process(data, line): Function called for each line in input stream. Required.
  • onerror(line, key, msg): Optional function called on errors. Set to null to ignore erors

Column Definition (config.columns):

Each column is either a Sting or Object. If it is Object !=null the following properties are assumed:

  • key: The column id
  • type: optional - text|date|number|boolean - defaults to text

If it is String the format "key(type)" is allowed. Otherwise the String is taken as key with type=text as format.

null columns are ignored

Return value:

A csvReader object with one method

  • read(filename_or_stream_or_file, [encoding])

The default encoding is utf8.


config object

Return value csvReader object
Allowed in script types
  • WebTML pages and normal WebTML actions
  • Master actions
  • TMLScript tasks in jobs
  • Content type events
skipLines: 1,
columns: [
{key:"created",type:"date"}, // same as "created(date)"
null, // ignore this column / field
process: function(data){...}