larray.Session.save

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

Dumps Array objects from the current session to a file (all formats). Dumps also Axis and Group objects from the current session to a file (HDF and pickle format).

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 Array/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.

Examples

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

Save all objects

>>> s.save('output.h5')                             

Save only some objects

>>> s.save('output.h5', ['a', 'b', 'arr1'])         

Update file

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