5.1.4.2. Base writer classes of text formats

class pytablewriter.writer.text._text_writer.TextTableWriter[source]

Bases: pytablewriter.writer._table_writer.AbstractTableWriter, pytablewriter.writer.text._interface.TextWriterInterface

A base class for table writer with text formats.

table_char

Character attributes that compose a table

column_delimiter: str

A column delimiter of a table.

char_left_side_row: str

A character of a left side of a row.

char_right_side_row: str

A character of a right side of a row.

char_cross_point: str

A character of the crossing point of column delimiter and row delimiter.

char_opening_row: str

A character of the first line of a table.

char_header_row_separator: str

A character of a separator line of the header and the body of the table.

char_value_row_separator: str

A character of a row separator line of the table.

char_closing_row: str

A character of the last line of a table.

is_write_header_separator_row: bool

Write a header separator line of the table if the value is True.

is_write_value_separator_row: bool

Write row separator line(s) of the table if the value is True.

is_write_opening_row: bool

Write an opening line of the table if the value is True.

is_write_closing_row: bool

Write a closing line of the table if the value is True.

is_write_null_line_after_table: bool

Write a blank line of after writing a table if the value is True.

margin: int

Margin size for each cells

dump(output, close_after_write: bool = True, **kwargs) → None[source]

Write data to the output with tabular format.

Parameters
  • output (file descriptor or str) – file descriptor or path to the output file.

  • close_after_write (bool, optional) – Close the output after write. Defaults to True.

dumps(**kwargs) → str[source]

Get rendered tabular text from the table data.

Only available for text format table writers.

Parameters

**kwargs – Optional arguments that the writer takes.

Returns

Rendered tabular text.

Return type

str

write_null_line() → None[source]

Write a null line to the stream.

write_table(**kwargs) → None[source]

Write a table to the stream.

Note

  • None values are written as an empty string.

class pytablewriter.writer.text._text_writer.IndentationTextTableWriter[source]

Bases: pytablewriter.writer.text._text_writer.TextTableWriter, pytablewriter.writer.text._interface.IndentationInterface

A base class for table writer with indentation text formats.

indent_string

Indentation string for each level.

dec_indent_level() → None[source]

Decrement the current indent level.

inc_indent_level() → None[source]

Increment the current indent level.

set_indent_level(indent_level: int) → None[source]

Set the current indent level.

Parameters

indent_level (int) – New indent level.

write_table(**kwargs) → None[source]

Write a table to the stream.

Parameters

indent (Optional[int]) – Indent level of an output. Interpretation of indent level value differ format to format. Some writer classes may ignore this value.

Note

  • None values are written as an empty string.