iode.Lists.save

Lists.save(filepath: str, compress: bool = False)

Save objects of the current database into the file ‘filepath’.

Parameters:
filepath: str

path to the file to save.

compress: bool, optional

Whether or not to compress the file. If True, the file will be written using the LZH compression algorithm. This may slow down the writing process but will reduce the size of the saved file. Default to False.

Examples

>>> from pathlib import Path
>>> from iode import SAMPLE_DATA_DIR
>>> from iode import comments
>>> comments.load(f"{SAMPLE_DATA_DIR}/fun.cmt")
Loading .../fun.cmt
317 objects loaded 
>>> len(comments)
317
>>> # remove file if it already exists
>>> file_to_save = Path(f"{SAMPLE_DATA_DIR}/fun2.cmt")
>>> if file_to_save.exists():
...     file_to_save.unlink()
>>> # save the current Comments database into a new file
>>> comments.save(f"{SAMPLE_DATA_DIR}/fun2.cmt")
Saving fun2.cmt
317 objects saved
>>> # reload the database from the saved file
>>> comments.clear()
>>> comments.load(f"{SAMPLE_DATA_DIR}/fun2.cmt")
Loading .../fun2.cmt
317 objects loaded
>>> len(comments)
317