tsv: Tab-Separated Values in Python

This module defines two classes: a TsvWriter, which can be constructed on a stream to allow writing TSV data lines and #-delimited comments to that stream, and a TsvReader, which can be constructed on a stream and iterated over to obtain lists of the values from each non-comment line in the stream.

TSV is most useful as the basis for other, more tightly specified file formats.

Examples of how to use this module are available here: https://github.com/adamnovak/tsv/blob/master/README.md

class tsv.TsvReader(stream)

Represents a reader for tab-separated value files. Skips over comments starting with #. Can be iterated over.

Field values consisting of only whitespace are not allowed.

Make a new TsvReader to read from the given stream.

close()

Close the underlying stream.

class tsv.TsvWriter(stream)

Represents a writer for tab-separated value files containing #-delimited comments.

Make a new TsvWriter for writing TSV data to the given stream.

close()

Close the underlying stream.

comment(text)

Write the given text as a TSV comment. text must be a string containing no newlines.

line(*args)

Write the given values to the file, as a TSV line. Args holds a list of all arguments passed. Any argument that stringifies to a string legal as a TSV data item can be written.

list_line(line)

Write the given iterable of values (line) to the file as items on the same line. Any argument that stringifies to a string legal as a TSV data item can be written.

Does not copy the line or build a big string in memory.