zut.TabularDumper

class zut.TabularDumper(dst: T_TabularDumper_Dst, *, headers: Iterable[Header | Any] | None = None, truncate: bool = None, archivate: bool | str | Path | None = None, title: str | bool | None = None, dst_name: str | bool = True, dir: str | Path | Literal[False] | None = None, delay: bool = False, optional: str | Sequence[str] | Literal['*', True] | None = None, add_columns: bool | Literal['warn'] = False, after1970: bool | None = None, notz: bool | tzinfo | str | None = None, **kwargs)

Bases: Generic[T_TabularDumper_Dst]

__init__(dst: T_TabularDumper_Dst, *, headers: Iterable[Header | Any] | None = None, truncate: bool = None, archivate: bool | str | Path | None = None, title: str | bool | None = None, dst_name: str | bool = True, dir: str | Path | Literal[False] | None = None, delay: bool = False, optional: str | Sequence[str] | Literal['*', True] | None = None, add_columns: bool | Literal['warn'] = False, after1970: bool | None = None, notz: bool | tzinfo | str | None = None, **kwargs)

Methods

__init__(dst, *[, headers, truncate, ...])

append(row)

close()

Called at exit.

export(row)

Called for each exported row.

export_headers(headers)

Called at first exported row, if there are no pre-existing headers.

flush()

is_available()

new_headers(headers)

Called at first exported row, if there are headers that did not exist in pre-existing headers, and for dict rows having additional keys (if additional_headers is True).

open()

Called at first exported row, before headers are analyzed.

Attributes

after1970

foreign_id_keys

foreign_name_keys

truncate

dst

count

Number of appended rows.

exported_count

Number of exported rows.

close()

Called at exit.

count

Number of appended rows.

export(row: list)

Called for each exported row. Row has been prepared and is a list, with values already converted if necessary. Rows are already reordered to match order of existing rows (if any), i.e. they match self._combined_headers (if defined).

export_headers(headers: list[Header])

Called at first exported row, if there are no pre-existing headers.

exported_count

Number of exported rows.

new_headers(headers: list[Header]) bool | None

Called at first exported row, if there are headers that did not exist in pre-existing headers, and for dict rows having additional keys (if additional_headers is True).

Return None to prevent adding any new header, False to allow new columns but without a header name, and True to allow updating header names.

open() list[Header] | None

Called at first exported row, before headers are analyzed.

Return list of existing headers, or None if file/headers must be created.