nicetoolbox.utils.filehandling¶
Helper functions for reading, writing and parsing files
Functions
Recursively find all npz files in the given directory. |
|
Load JSON data from a file. |
|
Load TOML data from a file. |
|
Reads and returns the data from an NPZ file. |
- nicetoolbox.utils.filehandling.find_npz_files(directory)[source]¶
Recursively find all npz files in the given directory.
- Parameters:
directory (str) – The directory to search for npz files.
- Returns:
A list of paths to the npz files found in the directory.
- Return type:
npz_files (list)
- nicetoolbox.utils.filehandling.load_json_file(json_path: str) dict[source]¶
Load JSON data from a file.
- Parameters:
json_path (str) – The path to the JSON file.
- Returns:
The JSON data loaded from the file.
- Return type:
dict
- Raises:
FileNotFoundError – If the file does not exist.
json.JSONDecodeError – If the file contains invalid JSON data.
- nicetoolbox.utils.filehandling.load_toml(toml_path: str) dict[source]¶
Load TOML data from a file.
- Parameters:
toml_path (str) – The path to the TOML file.
- Returns:
The TOML data loaded from the file.
- Return type:
dict
- nicetoolbox.utils.filehandling.read_npz_file(filepath)[source]¶
Reads and returns the data from an NPZ file.
Supports loading data with the allow_pickle=True parameter.
- Parameters:
filepath (str) – The path to the NPZ file.
- Returns:
The data loaded from the NPZ file.
- Return type:
data (numpy.ndarray)