FileWriter#

class FileWriter(file: IO)[source]#

Bases: Generic, ABC

Base class for format writers.

Every writer needs a writable stream. The JSONL, CSV, and Avro writers write at the stream’s current position. JsonFileWriter rewrites its whole file on each write.

Variables:
  • mode (str) – Mode FilePublisher uses to open this writer’s file.

  • newline (str | None) – newline argument FilePublisher uses to open this writer’s file.

Wrap an open stream.

Parameters:

file (IO[AnyStr])

Stream that receives the records. Text or binary, per the format.

Raises:

ValueError – If the stream is not writable.

Attributes

Methods

write

Write one Measurement or Command to the stream.

mode: str#
newline: str | None = None#
abstractmethod write(
data: Measurement | Command,
) → None[source]#

Write one Measurement or Command to the stream.