cosapp.recorders.dsv_recorder

Recorder to Delimited Separated Value format file.

Classes

DSVRecorder(filepath[, includes, excludes, ...])

Record data into Delimiter Separated Value file.

class cosapp.recorders.dsv_recorder.DSVRecorder(filepath: str, includes: str | List[str] = '*', excludes: str | List[str] | None = None, numerical_only=False, section='', precision=9, hold=False, delimiter=',', raw_output=False, use_buffer=False)[source]

Bases: BaseRecorder

Record data into Delimiter Separated Value file.

Matching pattern are case sensitive and support the following special patterns:

Pattern

Meaning

*

matches everything

?

matches any single character

[seq]

matches any character in seq

[!seq]

matches any character not in seq

Excluding pattern are shadowing includes one; e.g. if includes=’*port_in.*’ and `excludes=’*.Pt’, for a port having variables named Tt and Pt, only Tt will be recorded.

Parameters:
  • filepath (str) – Filepath to save data into.

  • delimiter (‘,’, ‘;’ or ‘ ‘, optional) – Delimiter of data in the file; default ‘,’.

  • use_buffer (bool, optional) – Should the data written after the simulation (False) or every time they are available (True); default False.

  • includes (str or list of str, optional) – Variables matching these patterns will be included; default ‘*’ (i.e. all variables).

  • excludes (str or list of str or None, optional) – Variables matching these patterns will be excluded; default None (i.e. nothing is excluded).

  • numerical_only (bool, optional) – Keep only numerical variables (i.e. number or numerical vector); default False.

  • section (str, optional) – Current section name; default ‘’.

  • precision (int, optional) – Precision digits when writing floating point number; default 9 (i.e. 10 figures will be written).

  • hold (bool, optional) – Append the new data or not; default False.

  • raw_output (bool, optional) – Raw output; default False.

  • ..note:: – Do not mention inwards or outwards in includes or excludes list. Otherwise you may not record the wanted variables.

clear()[source]

Clear all previously stored data.

property delimiter: str

column delimiter used in DSV file

Type:

str

exit()[source]

Close recording session.

export_data() DataFrame[source]

Export recorded results into a pandas.DataFrame object.

property filepath: str

path of the DSV file

Type:

str

formatted_data() List[Any][source]

Format collected data from watched object into a list.

get_headers() List[str][source]

Returns the list of headers of DSV file.

start()[source]

Initialize recording support.