read_excel#

caf.van.utilities.read_excel(path, name=None, columns=None, **kwargs)[source]#

Wrapper function for pandas.read_excel to perform additional checks.

Reads file and provides more detailed error messages about missing columns.

Parameters:
  • path (Path) – Path to the XLSX file.

  • name (str, optional) – Human readable name of the file being read (used for error messages), by default None and uses the filename.

  • columns (Dict, list or tuple, default None) –

    • List or tuple - used for usecols parameter of pandas.read_excel.

    • Dict - used for the dtype and usecols parameter of pandas.read_excel, where keys are column name and values are data type.

    • None - reads in all columns from the XLSX.

  • kwargs (all other keyword arguments) – Passed to pandas.read_excel.

Returns:

DataFrame containing the information from the XLSX.

Return type:

pd.DataFrame

Raises:
  • MissingColumnsError – If any columns given don’t exist in the XLSX.

  • ValueError – If any of the columns cannot be converted to the given data type.