wholecell.io.tsv

CSV reader and writer that default to TAB delimiters.

class wholecell.io.tsv.dict_reader(f, fieldnames=None, **kwargs)[source]

Bases: object

Open a csv DictReader() defaulting to TAB delimiters. Fields whose names start with an underscore are removed from self._fieldnames, and discarded from each row during iteration.

REQUIRES: f must be a buffered byte reader, e.g. from io.open(filename, ‘rb’) or io.BytesIO(buffer).

Parameters:
property dialect: str | Dialect | Type[Dialect]
property fieldnames: list[str]
property line_num: int
wholecell.io.tsv.dict_writer(f, fieldnames, dialect='excel', **kwargs)[source]

Open a csv DictWriter() defaulting to TAB delimiters.

REQUIRES: csvfile must be a buffered byte writer, e.g. from io.open(filename, ‘wb’) or io.BytesIO(buffer).

Parameters:
Return type:

DictWriter

class wholecell.io.tsv.reader(csvfile, dialect='excel', delimiter='\t', **fmtparams)[source]

Bases: object

Open a csv reader() defaulting to TAB delimiters.

REQUIRES: csvfile must be a buffered byte reader, e.g. from io.open(filename, ‘rb’) or io.BytesIO(buffer).

This does Unicode by constructing the csv.reader with a TextIO.

Parameters:
property dialect: str | Dialect | Type[Dialect]
property line_num: int
next()
Return type:

list[str]

class wholecell.io.tsv.writer(csvfile, dialect='excel', delimiter='\t', **fmtparams)[source]

Bases: object

Open a csv writer() defaulting to TAB delimiters.

REQUIRES: csvfile must be a buffered byte writer, e.g. from io.open(filename, ‘wb’) or io.BytesIO(buffer).

This does Unicode by constructing the csv.writer with a TextIO.

Parameters:
property dialect: str | Dialect | Type[Dialect]
writerow(row)[source]
Parameters:

row (Sequence[Any])

writerows(rows)[source]
Parameters:

rows (Iterable[Sequence[Any]])