CSV File Writer


  • Plugin name : CSV File Writer
  • Version : 1.0
  • Author : Victor Herlin
  • Company : Mensia Technologies SA
  • Short description : Writes signal in a CSV (text based) file
  • Documentation template generation date : Dec 3 2018


This box writes incoming time series along with a stimulation stream into a text file using the Comma Separated Values format conforming to the RFC 4180 format.

The header of the CSV file contains some additional information that enables additional features during subsequent reading. This format is described in the Miscellaneous section.


1. Input stream

Time series input, this can be either a Signal, Streamed Matrix, Spectrum, Covariance Matrix or Feature Vector stream.

  • Type identifier : Signal (0x5ba36127, 0x195feae1)

2. Stimulations stream

Stimulations to be written alongside the signal.

  • Type identifier : Stimulations (0x6f752dd0, 0x082a321e)


1. Filename

Path of the CSV file to be written.

  • Type identifier : Filename (0x330306dd, 0x74a95f98)
  • Default value : [ record-[$core{date}-$core{time}].csv ]

2. Precision

Precision, in number of decimal digits, of the resulting data. For longer data the precision can significantly impact the file size.

  • Type identifier : Integer (0x007deef9, 0x2f3e95c6)
  • Default value : [ 10 ]

3. Append data

By default this box will overwrite data in the file if it exists. If this setting is set to true, the box will append data to the file instead. If the file is empty a header will be added as well. It is up to the user to ensure herself that the data written is of the same type and dimensions.

  • Type identifier : Boolean (0x2cdb2f0b, 0x12f231ea)
  • Default value : [ false ]

4. Only last matrix

If this setting is activated, only the last received matrix will be written to the file. This can be used, for example, with cumulative average box.

  • Type identifier : Boolean (0x2cdb2f0b, 0x12f231ea)
  • Default value : [ false ]


Example of writing a spectrum into a CSV file:

Writing a CSV file


The CSV Format

Example file containing Signal data and Stimulations

Signal file sampled at 8Hz, with epochs of 0.5s length. Note that the timestamps do not have an end time which is implicit.

In this example each x represents an arbitrary floating point value. The header contains the following rows:

  • Time:8Hz - contains the timestamp of each sample, this label also encodes the original sampling rate
  • Epoch - contains the number of the epoch in which each sample is contained, this allows encoding even overlapping signal
  • O1, O2, Pz, P3, P4 - channels containing EEG data
  • Event Id - contains a colon separated list of StimulationIds
  • Event Date - contains the same number of timestamps
  • Event Duration - is constructed in the same manner as Event Date
1 Time:8Hz,Epoch,O1,O2,Pz,P3,P4,Event Id,Event Date,Event Duration
2 0.00000,0,x,x,x,x,x,,,
3 0.12500,0,x,x,x,x,x,,,
4 0.25000,0,x,x,x,x,x,32000:32010,0.25000:0.25000,0:0
5 0.37500,0,x,x,x,x,x,,,
6 0.50000,1,x,x,x,x,x,,,
7 0.62500,1,x,x,x,x,x,,,
8 0.75000,1,x,x,x,x,x,35000,0.75250,0
9 0.87500,1,x,x,x,x,x,,,

Example file containing a three dimensional matrix

This example file contains 2x2x2 matrices produced every 0.125 seconds and spanning one second.

The labels for this matrix are:

  • for first dimension "LA", "LB"
  • for second dimension "1", "2"
  • for third dimension "X", "Y"
1 Time:2x2x2,End Time,LA:1:X,LA:1:Y,LA:2:X,LA:2:Y,LB:1:X,...,LB:2:Y,Event Id,Event Date,Event Duration
2 0.00000,1.00000,x,x,x,x,x,...,x,,,
3 0.12500,1.12500,x,x,x,x,x,...,x,,,
4 0.25000,1.25000,x,x,x,x,x,...,x,,,
5 0.37500,1.37500,x,x,x,x,x,...,x,,,
6 0.50000,1.50000,x,x,x,x,x,...,x,,,
7 0.62500,1.62500,x,x,x,x,x,...,x,,,
8 0.75000,1.75000,x,x,x,x,x,...,x,,,
9 0.87500,1.62500,x,x,x,x,x,...,x,,,
10 1.00000,2.00000,x,x,x,x,x,...,x,,,
11 1.12500,2.12500,x,x,x,x,x,...,x,,,
A label can be an empty string. If second dimension had an empty label then the first column would have label "LA::X", if it were the third dimension the column would have label "LA:1:"

Example file containing a spectrum

Spectrum file with 2 channels, 128Hz signal and spectra calculated on periods of 1 second every 0.125 seconds. The last element in the Time column (128) represents the original sampling rate.

1 Time:2x64:128,End Time,O1:0,O1:1.015873,...,O1:64,O2:0,...,O2:64,Event Id,Event Date,Event Duration
2 0.00000,1.00000,x,x,...,x,x,...,x,,,
3 0.12500,1.12500,x,x,...,x,x,...,x,,,
4 0.25000,1.25000,x,x,...,x,x,...,x,,,
5 0.37500,1.37500,x,x,...,x,x,...,x,,,
6 0.50000,1.50000,x,x,...,x,x,...,x,,,
7 0.62500,1.62500,x,x,...,x,x,...,x,,,
8 0.75000,1.75000,x,x,...,x,x,...,x,,,
9 0.87500,1.87500,x,x,...,x,x,...,x,,,
10 1.00000,2.00000,x,x,...,x,x,...,x,,,
11 1.12500,2.12500,x,x,...,x,x,...,x,,,