Writing

This module provides a set of utilities for writing TSV files.

class mysqltsv.writer.Writer(f, headers=None, none_string='NULL')[source]

Constructs a new TSV row writer.

Parameters:
f : file

A file pointer to write rows to

headers : list`(`str)

If a list of str is provided, use those strings as headers. Otherwise, no headers are written.

none_string : str

A string that will be written as None when read. (Defaults to “NULL”)

write(row)[source]

Writes a row to the output file.

Parameters:
row : list | dict | AbstractRow

Datastructure representing the row to write

mysqltsv.functions.write(rows, f, *args, **kwargs)[source]

Writes an iterable of rows to to a file in TSV format.

Parameters:
rows : iterable`(`list | dict | AbstractRow)

The rows to write.

f : file

A file pointer to write rows to

headers : list`(`str)

If a list of str is provided, use those strings as headers. Otherwise, no headers are written.

none_string : str

A string that will be written as None when read. (Defaults to “NULL”)

Previous topic

Reading

Next topic

Errors

This Page