read_csv#

caf.toolkit.io.read_csv(path, name=None, **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.

  • kwargs (keyword arguments) – All other keyword arguments are passed to pandas.read_csv.

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.