CSV Writer
Description
The "csvwriter" module consumes channel data and writes this data to Comma Separated Values (CSV) files.
Interfaces and protocols used
- NONE
JSON configuration
The following section describes the entire JSON configuration of the module and explains the individual parameters.
Example configuration (minimum)
{
"module": "CSVWriter",
"factory": "csvwriter",
"config":{
"channels":[
{
"name": "SomeChannelName"
}
]
}
}
Example configuration (maximum)
{
"module": "CSVWriter",
"factory": "csvwriter",
"config":{
"fileName":"/sde/<tag>/<date>/<date>_<time>.csv",
"tag": "preview",
"forceFileName": false,
"pollingIntervalMs":1000,
"maxFileDurationMs":900000,
"timeoutMs":15000,
"gridUs":10,
"fieldSep":",",
"structureSep":" ",
"decimalSep":".",
"timeFormat":"<date>T<time>.<us>Z",
"timeHeader": "Date/Time",
"timeDescription": "UTC",
"channels":[
{
"name": "SomeChannelName",
"field": "SomeColumnTitle",
"description": "SomeColumnSubtitle",
"defaultValue": "SomeDefaultValue",
"format":{
"fieldWith":8,
"fillChar":"-",
"base":10,
"format": "g",
"precision":6
}
},
{
"name": "SomeBooleanChannelName",
"field": "SomeColumnTitle",
"description": "SomeColumnSubtitle",
"defaultValue": "SomeDefaultValue",
"format":{
"falseValue": "FALSE",
"trueValue": "TRUE"
}
}
]
}
}
Example configuration (triggered recording)
{
"module": "CSVWriter",
"factory": "csvwriter",
"config":{
<CONFIGURATION>
"triggerChannel": "someBooleanTriggerChannel",
"triggerLeadTimeMs":30000,
"triggerFollowUpTimeMs":30000,
"triggerSeparateEvents":false,
"channels":[
<SPECIFICATION OF CHANNELS TO BE RECORDED>
]
}
}
Global module parameters
Parameter Name | Required | Data Type | Meaningful Value Range | Default | Description |
---|---|---|---|---|---|
fileName | No | STRING | see below | "/sde/"TAG"/"DATE"/"DATE"_"TIME".csv" | File name or structure of the file name (see below) |
forceFileName | No | BOOL | false, true | false | force constant specified file name |
tag | No | STRING | "preview" | tag name | |
pollingIntervalMs | No | INT | 1 - | 1000 | Polling Interval [ms] |
maxFileDurationMs | No | INT | 1 - | 900000 (15 min) | Maximum file duration [ms] |
timeoutMs | No | INT | 1 - | 15000 (15 s) | Timeout after which the latest new line (using specified default values) is written to the CSV file [ms] |
triggerChannel | No | STRING | Name of a Boolean trigger channel | ||
triggerLeadTimeMs | No | INT | 0 - | 15000 (15 s) | Trigger lead time |
triggerFollowUpTimeMs | No | INT | 0 - | 15000 (15 s) | Trigger follow-up time |
triggerSeparateEvents | No | BOOL | false, true | false | Closing the current file and opening a new file for overlapping trigger events |
gridMs | No | INT | 1 - | 1000 (1 s) | Sampling grid width [ms] (*) |
gridUs | No | INT | 1 - | 1000000 (1 s) | Sampling grid width [us] (*) |
gridNs | No | INT | 1 - | 1000000000 (1 s) | Sampling grid width [ns] (*) |
fieldSep | No | STRING | "," | column separator string | |
structureSep | No | STRING | " " | structure separator string | |
decimalSep | No | STRING | "." | decimal separator string | |
timeFormat | No | STRING | see below | "<date>T<time>.<ms>Z " | Date and time specification |
timeHeader | No | STRING | "" | Date and time header | |
timeDescription | No | STRING | "" | Date and time subheading | |
channels | YES | see below | Specification of channels to be recorded |
(*) optional
Specification of the file name 'fileName'
The file name is specified via a path, e.g.
/sde/<tag>/<date>/<date>_<time>.csv
Possible variables are:
<year>
(e.g. 2022)<month>
(e.g. 01)<day>
(e.g. 01)<hour>
(e.g. 01, 23)<minute>
(e.g. 01)<second>
(e.g. 01)<msecond>
(e.g. 001)<date>
:= "<year><month><day>
"<time>
:= "<hour><minute><second>
"<tag>
(see parameter 'tag')
Configuration of channels to be recorded 'channels'
Unlike in the OSF Writer module, for example, where all channels are recorded by default, a selection of channels must be specified in the CSV Writer. This is done via a list of JSON objects, which are to be parameterized as follows
Parameter name | Required | Data type | Meaningful value range | Default | Description |
---|---|---|---|---|---|
name | YES | STRING | Name of the smartCORE channel | ||
field | No | STRING | Name of the smartCORE channel | Column header of the channel | |
description | No | STRING | "" | Column subheading of the channel | |
defaultValue | No | STRING | "" | Default value to be written to the channel value cell in the event of a timeout if no channel data is available | |
format | No | see below | Specification with regard to which the channel value is formatted |
Configuration of the formatting of channel values 'format'
Boolean channel values can be formatted as follows
Parameter Name | Required | Data Type | Meaningful Value Range | Default | Description |
---|---|---|---|---|---|
trueValue | YES | STRING | Value that is written to the channel value cell if true | ||
falseValue | YES | STRING | Value that is written to the channel value cell in the event of false |
All other values can be formatted as follows
Parameter name | Required | Data type | Meaningful value range | Default | Description |
---|---|---|---|---|---|
fieldWidth | No | INT | ColumnWidth | ||
fillChar | No | CHAR | fill character | ||
base | No | INT | 2, 8, 10, 16 | 10 | Base of number representation |
format | No | CHAR | "e", "f", "g" | "g" | Notation of the number representation ("e" => scientific N., "f" => normal representation, "g" => either normal or scientific N.) |
precision | No | INT | 0 - | Precision (number of decimal places) |
Module information
Information | Value |
---|---|
Authors | optiMEAS Measurement and Automation Systems GmbH |
since smartCORE | 2.8 |
Module type | Consumer |
Dependencies | NONE |