meyelens.fileio
- class meyelens.fileio.FileWriter(path_to_file, filename: str = '', append: bool = False, sep: str = ';')[source]
Bases:
objectSimple synchronous text file writer.
This class creates a timestamped
.txtfile and exposes convenience methods to write either a single string (one line) or a list of values separated by a custom delimiter.Notes
This writer is synchronous: each call writes directly to disk.
The filename is always timestamped to reduce accidental overwrites.
The file is opened immediately on initialization and must be closed by calling
close().
- write(stringa: str) None[source]
Write a single line to the file.
- Parameters:
stringa (str) – Line content. A newline character is automatically appended.
- write_sv(lista) None[source]
Write a list of values as a separator-joined line.
- Parameters:
lista (iterable) – Values to serialize. Each element is converted to
str. The resulting line is written with a trailing newline.
- class meyelens.fileio.BufferedFileWriter(path_to_file, filename: str = '', buffer_size: int = 100, metadata=None, headers=None, sep: str = ';')[source]
Bases:
objectBuffered asynchronous text file writer.
This writer uses an in-memory
queue.Queueas a buffer and a background thread to flush lines to disk. This is useful for time-critical data acquisition loops where direct disk writes would introduce latency.The file format is:
optional metadata lines (prefixed with
#)a header row (separator-joined)
data rows (one per buffered entry)
Notes
The background thread is started automatically at initialization.
Call
close()to stop the thread and ensure all queued data is written.If the buffer is full, new entries are discarded and a
printwarning is emitted (per your request, no logging is used).
- write(string: str) None[source]
Queue a pre-formatted line for writing.
- Parameters:
string (str) – The line to write (without a trailing newline). A newline will be appended by the writer thread.
Notes
If the buffer is full, the value is discarded and a warning is printed.