find_filename#

caf.toolkit.io.find_filename(path, alt_types=None, return_full_path=True)[source]#

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

If path ends in a file extension, will try find that file first. If that doesn’t exist, it will look for a compressed, or ‘.csv’ version.

Parameters:
  • path (PathLike) – The path to the file to try and find

  • alt_types (list[str] | None) – A list of alternate filetypes to consider. By default, will be: [‘.pbz2’, ‘.csv’]

  • return_full_path (bool) – If False, will only return the name of the file, and not the full path

Returns:

The path to a matching, or closely matching (differing only on filetype extension) file.

Return type:

path

Raises:

FileNotFoundError: – If the file cannot be found under any of the given alt_types file extensions.