Skip to main content

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 NameRequiredData TypeMeaningful Value RangeDefaultDescription
fileNameNoSTRINGsee below"/sde/"TAG"/"DATE"/"DATE"_"TIME".csv"File name or structure of the file name (see below)
forceFileNameNoBOOLfalse, truefalseforce constant specified file name
tagNoSTRING"preview"tag name
pollingIntervalMsNoINT1 -1000Polling Interval [ms]
maxFileDurationMsNoINT1 -900000 (15 min)Maximum file duration [ms]
timeoutMsNoINT1 -15000 (15 s)Timeout after which the latest new line (using specified default values) is written to the CSV file [ms]
triggerChannelNoSTRINGName of a Boolean trigger channel
triggerLeadTimeMsNoINT0 -15000 (15 s)Trigger lead time
triggerFollowUpTimeMsNoINT0 -15000 (15 s)Trigger follow-up time
triggerSeparateEventsNoBOOLfalse, truefalseClosing the current file and opening a new file for overlapping trigger events
gridMsNoINT1 -1000 (1 s)Sampling grid width [ms] (*)
gridUsNoINT1 -1000000 (1 s)Sampling grid width [us] (*)
gridNsNoINT1 -1000000000 (1 s)Sampling grid width [ns] (*)
fieldSepNoSTRING","column separator string
structureSepNoSTRING" "structure separator string
decimalSepNoSTRING"."decimal separator string
timeFormatNoSTRINGsee below"<date>T<time>.<ms>Z"Date and time specification
timeHeaderNoSTRING""Date and time header
timeDescriptionNoSTRING""Date and time subheading
channelsYESsee belowSpecification 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 nameRequiredData typeMeaningful value rangeDefaultDescription
nameYESSTRINGName of the smartCORE channel
fieldNoSTRINGName of the smartCORE channelColumn header of the channel
descriptionNoSTRING""Column subheading of the channel
defaultValueNoSTRING""Default value to be written to the channel value cell in the event of a timeout if no channel data is available
formatNosee belowSpecification 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 NameRequiredData TypeMeaningful Value RangeDefaultDescription
trueValueYESSTRINGValue that is written to the channel value cell if true
falseValueYESSTRINGValue that is written to the channel value cell in the event of false

All other values can be formatted as follows

Parameter nameRequiredData typeMeaningful value rangeDefaultDescription
fieldWidthNoINTColumnWidth
fillCharNoCHARfill character
baseNoINT2, 8, 10, 1610Base of number representation
formatNoCHAR"e", "f", "g""g"Notation of the number representation ("e" => scientific N., "f" => normal representation, "g" => either normal or scientific N.)
precisionNoINT0 -Precision (number of decimal places)

Module information

InformationValue
AuthorsoptiMEAS Measurement and Automation Systems GmbH
since smartCORE2.8
Module typeConsumer
DependenciesNONE