File utils
all_files(directory)
Obtains all files from a given directory.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
directory |
Path
|
The directory path. |
required |
Returns:
Type | Description |
---|---|
list[Path]
|
list[Path]: A list of Path objects representing all files in the directory. |
Source code in src/pheval/utils/file_utils.py
31 32 33 34 35 36 37 38 39 40 41 42 43 |
|
ensure_columns_exists(cols, dataframes, err_message='')
Ensures the columns exist in dataframes passed as argument (e.g)
" ensure_columns_exists( cols=['column_a', 'column_b, 'column_c'], err_message="Custom error message if any column doesn't exist in any dataframe passed as argument", dataframes=[data_frame1, data_frame2], ) "
Source code in src/pheval/utils/file_utils.py
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
|
ensure_file_exists(*files)
Ensures the existence of files passed as parameter Raises: FileNotFoundError: If any file passed as a parameter doesn't exist a FileNotFound Exception will be raised
Source code in src/pheval/utils/file_utils.py
73 74 75 76 77 78 79 80 |
|
files_with_suffix(directory, suffix)
Obtains all files ending in a specified suffix from a given directory.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
directory |
Path
|
The directory path. |
required |
suffix |
str
|
The specified suffix to filter files. |
required |
Returns:
Type | Description |
---|---|
list[Path]
|
list[Path]: A list of Path objects representing files with the specified suffix. |
Source code in src/pheval/utils/file_utils.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
|
is_gzipped(file_path)
Confirms whether a file is gzipped.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_path |
Path
|
The path to the file. |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if the file is gzipped, False otherwise. |
Source code in src/pheval/utils/file_utils.py
46 47 48 49 50 51 52 53 54 55 56 |
|
normalise_file_name(file_path)
Normalises the file name by removing diacritical marks (accents) from Unicode characters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_path |
Path
|
The path to the file. |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The normalised file name without diacritical marks. |
Source code in src/pheval/utils/file_utils.py
59 60 61 62 63 64 65 66 67 68 69 70 |
|
write_metadata(output_dir, meta_data)
Write the metadata for a run to a YAML file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
output_dir |
Path
|
The directory where the metadata file will be saved. |
required |
meta_data |
BasicOutputRunMetaData
|
The metadata to be written. |
required |
Source code in src/pheval/utils/file_utils.py
108 109 110 111 112 113 114 115 116 117 118 |
|