tsv2dict

Provides a reader and writer for TSV files, similar to the CSV implementation.

class tsv2dict.DictConverter(type_dict: Dict[str, Callable[[str], Any]])[source]

An object that parses a dict of strings into the types specified in type_dict

class tsv2dict.DictReader(f: Iterable[str], fieldnames: Optional[List[str]] = None)[source]

Allows reading of tsv files in the form of dicts.

class tsv2dict.DictWriter(f: TextIO, write_header: bool, fieldnames: Optional[Sequence[str]] = None, missing_values_placeholder: Optional[str] = None, allow_excess_values: bool = False)[source]

Allows writing of dict values to a new or existing tsv file.

write_row(rowdict: Dict[str, Any])None[source]

Writes a dict into the TSV as a single line

write_rows(rowdicts: Iterable[Dict[str, Any]])[source]

Adds several dicts in the form of as many rows

class tsv2dict.ListConverter(type_list: List[Callable[[str], Any]])[source]

An object that parses a list of strings into the types specified in type_list

class tsv2dict.Reader(f: Iterable[str])[source]

Reads and unexcapes rows of tsv line by line.

class tsv2dict.Writer(f: TextIO)[source]

Writes rows into a tsv file. Performs escaping.

write_row(cells: Iterable[Optional[str]])None[source]

Writes a single row into a tsv file. Performs escaping.

tsv2dict.escape(cell: Optional[str])str[source]

Make a string unambiguous when used in a tsv

tsv2dict.unescape(cell: str)Optional[str][source]

Deserialize a string from the tsv storage format