caf.toolkit.io#

Common utility functions for file input and output.

Module Attributes

NORMALISED_CHARACTERS

Characted allowed in normalised column names.

Functions

check_file_exists(file_path[, find_similar])

Checks if a file exists at the given path.

file_exists(file_path)

Checks if a file exists at the given path.

find_file_with_name(folder, name, suffixes)

Find a file in a folder matching _any_ acceptable suffix.

find_filename(path[, alt_types, ...])

Checks if the file at path exists under a different file extension.

read_csv(path[, name, normalise_column_names])

Read CSV files, wraps pandas.read_csv to perform additional checks.

read_csv_matrix(path[, format_])

Read matrix CSV in the square or long format.

read_df(path[, index_col, find_similar])

Reads in the dataframe at path.

read_matrix(path[, format_, find_similar])

Read matrix CSV in the square or long format.

remove_suffixes(path)

Removes all suffixes from path

safe_dataframe_to_csv(df, *args, **kwargs)

Prompt the user to close a file before saving.

starts_with(s, x)

Boolean test to see if string s starts with string x or not.

write_df(df, path, **kwargs)

Writes the dataframe at path.

Classes

Any(*args, **kwargs)

Special type indicating an unconstrained type.

Callable()

Hashable()

Iterable()

Sequence()

All the operations on a read-only sequence.

TypeVar(name, *constraints[, bound, ...])

Type variable.

Exceptions

MissingColumnsError(name, columns, *args, ...)

Raised when columns are missing from input CSV.

Attributes Documentation

caf.toolkit.io.NORMALISED_CHARACTERS = 'abcdefghijklmnopqrstuvwxyz0123456789!#$%£&\\-.<=>+^_~\\(\\)'#

Characted allowed in normalised column names.