CSV handling

Open CSV file

The data-csv action specifies a CSV file from which data will be read.

Name Type Required Action Info
file string Yes No CSV filename. It must be uploaded in the system using the load data API.
name string Yes No Identifier given to the file to use in read operations.
headers boolean No No Indicates the presence of headers on the file; the default is "false".

Example

{"data-csv" : {
                "file" : "csv_e2e.csv",
                "name" : "csvdata"
              }
}

Note: The fields in CSV fiels should be seperated by commas only. Quotation marks are not required unless they should be included in the field value.

Read CSV file

The data-csv_value action loads each line from the CSV file specified in the data-csv action. It uses circular reading, so it will start reading again from the beginning once the end is reached. This action retrieves one line at each time. Fields are stored in the variables provided. fields and vars must contain the same number of elements. The action returns 'ok'.

Name Type Required Action Info
name string Yes No File identifier.
fields list of integer Yes No Numbers of the CSV columns to be retrieved.
vars list of string Yes No Names of the variables to store the retrieved fields.

A row can be read by using field indexes in ascending order. Note that the field index starts with 1 (so the index of the first value in a line is 1).

Example

{"data-csv_value" : {
                "name" : "csvdata",
                "fields" : [1,3],
                "vars" : ["name","date"]
              }
}