eta_nexus.subscription_handlers.csv_subscription_handler module

class eta_nexus.subscription_handlers.csv_subscription_handler.CsvSubscriptionHandler(output_file: Path, write_interval: TimeStep = 1, size_limit: int = 1024, dialect: type[csv.Dialect] = <class 'csv.excel'>)[source]

Bases: SubscriptionHandler

Handle data for a subscription and save it as a CSV file.

Parameters:
  • output_file – CSV file to write data to.

  • write_interval – Interval between rows in the CSV file (value that time is rounded to)

  • size_limit – Size limit for the csv file. A new file with a unique name will be created when the size is exceeded.

  • dialect – Dialect of the csv file. This takes objects, which correspond to the csv.Dialect interface from the python csv module.

push(node: Node, value: Any, timestamp: datetime | None = None) None[source]

Receive data from a subscription. THis should contain the node that was requested, a value and a timestamp when data was received. If the timestamp is not provided, current time will be used.

Parameters:
  • node – Node object the data belongs to.

  • value – Value of the data.

  • timestamp – Timestamp of receiving the data.

close() None[source]

Finalize and close the subscription handler.