read_csv#
- caf.toolkit.io.read_csv(path, name=None, normalise_column_names=False, **kwargs)[source]#
Read CSV files, wraps pandas.read_csv to perform additional checks.
Provides more detailed error messages about missing columns.
- Parameters:
path (Path) – Path to the CSV file (can be “.csv” or “.txt”).
name (str, optional) – Human readable name of the file being read (used for error messages), if not given uses the filename.
normalise_columns (bool, default False) – Replace spaces with underscores, convert to lowercase and remove any characters not in
NORMALISE_CHARACTERS.kwargs (keyword arguments) – All other keyword arguments are passed to pandas.read_csv.
normalise_column_names (bool)
- Returns:
DataFrame containing the information from the CSV.
- Return type:
pd.DataFrame
- Raises:
MissingColumnsError – If any columns given in usecols don’t exist in the CSV.
ValueError – If any of the columns in dtype cannot be converted to the given data type.