pyfvcom2.file_utils module
Tools to assist with file handling.
- pyfvcom2.file_utils.find_file(dir_name: str, file_stem: str, date_time: datetime, tolerance_hours: int | None = 0) str
Find a file in a directory matching a given stem and containing date_time within a given tolerance.
- Parameters:
dir_name (str) – Directory to search for files.
file_stem (str) – Stem of the file name to match.
date_time (datetime) – Datetime to match in the file name.
tolerance_hours (int, optional) – Tolerance in hours for datetime matching. Defaults to 1.
- Returns:
Path to the matched file. int: Index of the time variable corresponding to the matched datetime.
- Return type:
str
- Raises:
PyFVCOM2FileNotFoundError – If no matching file is found within the tolerance.
- pyfvcom2.file_utils.find_files(dir_name: str, file_stem: str, start_date_time: datetime, end_date_time: datetime, tolerance_hours: int | None = 0) list[str]
Find all files in a directory matching a given stem and containing datetimes within a given range.
- Parameters:
dir_name (str) – Directory to search for files.
file_stem (str) – Stem of the file name to match.
start_date_time (datetime) – Start datetime to match in the file name.
end_date_time (datetime) – End datetime to match in the file name.
tolerance_hours (int, optional) – Tolerance in hours for datetime matching. Defaults to 1.
- Returns:
List of paths to the matched files.
- Return type:
list[str]