src.pydasa.core.io#
Generic I/O operations for PyDASA.
This module provides functions for reading and writing data to files, handling different data formats (JSON, CSV, etc.), and ensuring compatibility with the data structures used in PyDASA.
IMPORTANT: based on the implementations proposed by the following authors/books:
Algorithms, 4th Edition, Robert Sedgewick and Kevin Wayne.
Data Structure and Algorithms in Python, M.T. Goodrich, R. Tamassia, M.H. Goldwasser.
Attributes#
Functions#
|
load_json() reads a JSON file and returns its content as a dictionary. |
|
save_json() writes a dictionary to a JSON file. |
|
load() generic load function - detects format from file extension. |
|
save() generic save function - detects format from file extension. |
Module Contents#
- src.pydasa.core.io.READ = 'r'#
- src.pydasa.core.io.WRITE = 'w'#
- src.pydasa.core.io.PATTERN = 'utf-8'#
- src.pydasa.core.io.AVAIL_FMT = ['.json']#
- src.pydasa.core.io.load_json(file_path)#
load_json() reads a JSON file and returns its content as a dictionary.
- src.pydasa.core.io.save_json(data, file_path, indent=4)#
save_json() writes a dictionary to a JSON file.
- src.pydasa.core.io.load(file_path)#
load() generic load function - detects format from file extension.
- Parameters:
file_path (str | Path) – Input file path.
- Raises:
ValueError – If unsupported file format.
- Returns:
Loaded data as a dictionary.
- Return type:
- src.pydasa.core.io.save(data, file_path, **kwargs)#
save() generic save function - detects format from file extension.
- Parameters:
- Raises:
ValueError – If unsupported file format.
- Return type:
None