data_io#
Save and load data in multiple formats (CSV, pickle, compressed pickle, JSON) with automatic directory creation, elapsed-time logging, and file-size reporting.
See data_io for usage examples.
API Reference#
- pyedautils.data_io.save_data(data: Any, file_path: str, index: bool = False) None[source]#
Saves data to a file in various formats (CSV, Pickle, JSON) based on the given file extension of file_path.
- Parameters:
data – The data to be saved. Should be a pandas DataFrame or a Python object.
file_path (str) – The path to the file where the data will be saved.
index (bool, optional) – Whether to write the DataFrame index. Default is False.
- Raises:
ValueError – If the file format is not supported.
- Returns:
None
- pyedautils.data_io.load_data(file_path: str) DataFrame | Any | None[source]#
Loads data from a file in various formats (CSV, Pickle, JSON) based on the given file extension of file_path.
- Parameters:
file_path (str) – The path to the file from which data will be loaded.
- Raises:
ValueError – If the file format is not supported.
- Returns:
The loaded data as a pandas DataFrame or a Python object.
- Return type:
data