Skip to content

Module: micpy.tab

The micpy.tab module provides methods to read and parse tabular files.

FormatError

Bases: Exception

Raised when there's a problem with the format of the tabular file.

parse(string, parse_header=True, ignore_invalid_header=True)

Parse a tabular file and return the content as a pandas DataFrame.

Parameters:

Name Type Description Default
string str

The content of a tabular file as a string.

required
parse_header bool

Whether to parse the header. Defaults to True.

True
ignore_invalid_header bool

Whether to ignore invalid headers. Defaults to True.

True

Raises:

Type Description
`FormatError`

If the number of columns in the header does not match the body.

Returns:

Type Description
DataFrame

The content of the file as a pandas DataFrame.

read(filename, parse_header=True, ignore_invalid_header=True)

Read a tabular file and return the content as a pandas DataFrame.

Parameters:

Name Type Description Default
filename str

Path to the file.

required
parse_header bool

Whether to parse the header. Defaults to True.

True
ignore_invalid_header bool

Whether to ignore invalid headers. Defaults to True.

True

Raises:

Type Description
`FormatError`

If the number of columns in the header does not match the body.

Returns:

Type Description
DataFrame

The content of the file as a pandas DataFrame.