mtnlion.tools.loader module¶
This module provides utilities for loading and saving data in various file formats.
-
mtnlion.tools.loader.
collect_files
(file_list: List[str], format_key: Callable = <function format_name>, loader: Callable = <function load_numpy_file>, **kwargs) → Dict[str, numpy.ndarray][source]¶ Collect files using the provided loader.
Collect files given as a list of filenames using the function loader to load the file and the function format_key to format the variable name. :param file_list: list of filenames :param format_key: function to format variable names :param loader: function to load files :param kwargs: extra arguments to the loader :return: data dictionary
-
mtnlion.tools.loader.
format_name
(name: str) → str[source]¶ Do nothing for formatting names and log the event.
- Parameters
name – filename
- Returns
variable name
-
mtnlion.tools.loader.
load_csv_file
(filename: str, comments: str = '%', delimiter: str = ', ', d_type: type = <class 'numpy.float64'>, **kwargs) → numpy.ndarray[source]¶ Load data from a csv file. See numpy.load for additional argument options.
- Parameters
filename – name of the csv file
comments – lines starting with a comment will be ignored
delimiter – delimiting character(s)
d_type – data type
kwargs – additional numpy.loadtxt arguments
- Returns
file data
-
mtnlion.tools.loader.
load_numpy_file
(filename: str, **kwargs) → Dict[str, numpy.ndarray][source]¶ Load data from an npz file. See numpy.load for additional argument options.
- Parameters
filename – name of the npz file
kwargs – additional numpy.load arguments
- Returns
data dictionary
-
mtnlion.tools.loader.
save_npz_file
(filename: str, data_dict: Dict[str, numpy.ndarray], **kwargs) → None[source]¶ Save data to an npz file. See numpy.savez for additional argument options.
- Parameters
data_dict – data to be saved to an npz file
filename – name of the npz file
kwargs – additional numpy.savez arguments