typeddfs._mixins._flexwf_mixin

Mixin for flex-wf.

Module Contents

class typeddfs._mixins._flexwf_mixin._FlexwfMixin
classmethod read_flexwf(cls, path_or_buff, sep: str = '\\|\\|\\|', **kwargs) __qualname__

Reads a “flexible-width format”. The delimiter (sep) is important. Note that ``sep`` is a regex pattern if it contains more than 1 char.

These are designed to read and write (to_flexwf) as though they were fixed-width. Specifically, all of the columns line up but are separated by a possibly multi-character delimiter.

The files ignore blank lines, strip whitespace, always have a header, never quote values, and have no default index column unless given by required_columns(), etc.

Parameters
  • path_or_buff – Path or buffer

  • sep – The delimiter, a regex pattern

  • kwargs – Passed to read_csv; may include ‘comment’ and ‘skip_blank_lines’

to_flexwf(self, path_or_buff=None, sep: str = '|||', mode: str = 'w', **kwargs) Optional[str]

Writes a fixed-width formatter, optionally with a delimiter, which can be multiple characters.

See read_flexwf for more info.

Parameters
  • path_or_buff – Path or buffer

  • sep – The delimiter, 0 or more characters

  • mode – write or append (w/a)

  • kwargs – Passed to Utils.write; may include ‘encoding’

Returns

The string data if path_or_buff is a buffer; None if it is a file