larray.Session.save

Session.save(self, fname, names=None, engine='auto', overwrite=True, display=False, **kwargs)[source]

Dumps LArray, Axis and Group objects from the current session to a file.

Parameters
fnamestr

Path of the file for the dump. If objects are saved in CSV files, the path corresponds to a directory.

nameslist of str or None, optional

List of names of LArray/Axis/Group objects to dump. If fname is None, list of paths to CSV files. Defaults to all objects present in the Session.

engine{‘auto’, ‘pandas_csv’, ‘pandas_hdf’, ‘pandas_excel’, ‘xlwings_excel’, ‘pickle’}, optional

Dump using engine. Defaults to ‘auto’ (use default engine for the format guessed from the file extension).

overwrite: bool, optional

Whether or not to overwrite an existing file, if any. Ignored for CSV files and ‘pandas_excel’ engine. If False, file is updated. Defaults to True.

displaybool, optional

Whether or not to display which file is being worked on. Defaults to False.

Notes

See Notes section from to_csv() and to_excel().

Examples

>>> # axes
>>> a, b = Axis("a=a0..a2"), Axis("b=b0..b2")    # doctest: +SKIP
>>> # groups
>>> a01 = a['a0,a1'] >> 'a01'                    # doctest: +SKIP
>>> # arrays
>>> arr1, arr2 = ndtest((a, b)), ndtest(a)       # doctest: +SKIP
>>> s = Session([('a', a), ('b', b), ('a01', a01), ('arr1', arr1), ('arr2', arr2)])  # doctest: +SKIP
>>> # metadata
>>> s.meta.title = 'my title'                    # doctest: +SKIP
>>> s.meta.author = 'John Smith'                 # doctest: +SKIP

Save all objects

>>> s.save('output.h5')                             # doctest: +SKIP

Save only some objects

>>> s.save('output.h5', ['a', 'b', 'arr1'])         # doctest: +SKIP

Update file

>>> arr1, arr4 = ndtest((3, 3)), ndtest((2, 3))     # doctest: +SKIP
>>> s2 = Session([('arr1', arr1), ('arr4', arr4)])  # doctest: +SKIP
>>> # replace arr1 and add arr4 in file output.h5
>>> s2.save('output.h5', overwrite=False)           # doctest: +SKIP