FilePublisher#
- class FilePublisher(
- directory: str | Path | None = None,
- format: Literal['json', 'jsonl', 'csv', 'avro'] = 'avro',
- custom_file_name: str | None = None,
- *,
- file: IO[Any] | None = None,
Bases:
objectWrite Measurement/Command data to a file or to an open stream.
- Parameters:
directory
Output directory, created if missing. Defaults to
instro-measurementsin the current working directory.format
"jsonl","csv","avro"(default), or"json"(deprecated).custom_file_name
Filename without extension; defaults to
measurements-<local-timestamp>.file
Open stream to write to instead of a file: binary for
"avro", text for"jsonl"and"csv"."json"does not support streams.close()leaves the stream open.
- Raises:
ValueError – If
fileis combined withdirectory,custom_file_name, or"json", the format is unknown, orfileis the wrong kind of stream for the format.
Methods
Close the file this publisher opened.
Publish data to file using the appropriate writer.
- publish(
- data: Measurement | Command,
- **kwargs,
Publish data to file using the appropriate writer.