odatse.util.data_writer module

class odatse.util.data_writer.BaseWriter(filename=None, mode='w', combined=False)[source]

Bases: object

Base class for file writing operations with support for combined output files.

Class Attributes

_fpTextIO | None

Shared file pointer for combined output mode

_fp_countint

Reference counter for combined file pointer

_combined_filenamestr

Default filename for combined output

_combined_filemodestr

Default file mode for combined output

Initialize writer with file handling options.

param filename:

Path to output file

type filename:

str | None

param mode:

File open mode (‘w’ for write, ‘a’ for append)

type mode:

str

param combined:

If True, writes to a shared combined file instead of individual files

type combined:

bool

__init__(filename=None, mode='w', combined=False)[source]

Initialize writer with file handling options.

Parameters:
  • filename (str | None) – Path to output file

  • mode (str) – File open mode (‘w’ for write, ‘a’ for append)

  • combined (bool) – If True, writes to a shared combined file instead of individual files

_write(*args)[source]

Internal write method handling both combined and individual file modes.

In combined mode, prefixes each line with the source filename tag.

classmethod basicConfig(combined_filename=None, combined_mode=None)[source]

Configure global settings for combined file output.

class odatse.util.data_writer.DataWriter(filename=None, mode='w', item_list=[], *, description=None, long_format=False, combined=False)[source]

Bases: BaseWriter

Specialized writer for structured data output with header support.

Extends BaseWriter to handle formatted data output with column headers and optional descriptions.

Initialize data writer with column specifications.

Parameters:
  • filename (str | None) – Output file path

  • mode (str) – File open mode

  • item_list (list) – List of column specifications (name, format, description)

  • description (str | None) – Optional file header description

  • long_format (bool) – If True, writes detailed column descriptions

  • combined (bool) – If True, writes to shared combined file

__init__(filename=None, mode='w', item_list=[], *, description=None, long_format=False, combined=False)[source]

Initialize data writer with column specifications.

Parameters:
  • filename (str | None) – Output file path

  • mode (str) – File open mode

  • item_list (list) – List of column specifications (name, format, description)

  • description (str | None) – Optional file header description

  • long_format (bool) – If True, writes detailed column descriptions

  • combined (bool) – If True, writes to shared combined file

_write_header(description, long_format)[source]

Write file header with column descriptions.

Parameters:
  • description (str | None) – Optional file description

  • long_format (bool) – If True, writes detailed per-column descriptions

_write_items(items)[source]

Write a row of data values with proper formatting.

Parameters:

items (sequence) – Values to write, must match header length

class odatse.util.data_writer.TextWriter(filename=None, mode='w', *, combined=False)[source]

Bases: BaseWriter

Initialize writer with file handling options.

Parameters:
  • filename (str | None) – Path to output file

  • mode (str) – File open mode (‘w’ for write, ‘a’ for append)

  • combined (bool) – If True, writes to a shared combined file instead of individual files