modelCSVWriter

Model for writing results to a .csv file

Extends from Buildings.Utilities.IO.Files.BaseClasses.FileWriter (Partial model for writing results to a .csv file).

Information

This model samples the model inputs u and saves them to a .csv file, which can be read using e.g. Excel or Python.

Typical use and important parameters

The parameter nin defines the number of variables that are stored. In Dymola, this parameter is updated automatically when inputs are connected to the component.

The parameter fileName defines to what file name the results are saved. The file is in the current working directory, unless an absolute path is provided.

The parameter samplePeriod defines every how many seconds the inputs are saved to the file.

Options

The parameter delimiter can be used to choose a custom separator.

By default the first line of the csv file consists of the file header. The column names can be defined using parameter headerNames. The header can be removed by setting writeHeader=false

Dynamics

This model samples the outputs at an equidistant interval and hence disregards the simulation tool output interval settings.

Parameters

TypeNameDefaultDescription
Integernin (from FileWriter)Number of inputs
StringfileName (from FileWriter)getInstanceName() + ".csv"File name, including extension
Modelica.Units.SI.TimesamplePeriod (from FileWriter)Sample period: equidistant interval for which the inputs are saved
Advanced
Stringdelimiter (from FileWriter)"\t"Delimiter for csv file
BooleanwriteHeader (from FileWriter)true=true, to write header with variable names, otherwise no header will be written
StringheaderNames (from FileWriter){"col" + String(i) for i in 1:nin}Header names, indices by default
IntegersignificantDigits (from FileWriter)6Number of significant digits that are used for converting inputs into string format

Connectors

TypeNameDefaultDescription
Modelica.Blocks.Interfaces.RealVectorInputu (from FileWriter)Variables that are saved

Revisions

  • October 17, 2019 by Filip Jorissen:
    Avoiding overflow of string buffer in dymola. See #1219.
  • July 7, 2018 by Filip Jorissen:
    First implementation. See #924.