larray.Session.to_csv

Session.to_csv(fname, names=None, display=False, **kwargs) None[source]

Dump Array objects from the current session to CSV files.

Parameters
fnamestr

Path for the directory that will contain CSV files.

nameslist of str or None, optional

Names of Array objects to dump. Defaults to all Array objects present in the Session.

displaybool, optional

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

Notes

  • each array is saved in a separate file

  • all session metadata is saved in the same CSV file named __metadata__.csv

Examples

>>> # scalars
>>> i, s = 5, 'string'                                                      
>>> # 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)                                  
>>> ses = Session({'i': i, 's': s, 'a': a, 'b': b, 'a01': a01,
...                'arr1': arr1, 'arr2': arr2})                             
>>> # metadata
>>> ses.meta.title = 'my title'                                             
>>> ses.meta.author = 'John Smith'                                          

Save all arrays (and arrays only)

>>> ses.to_csv('output', display=True)                                      
dumping i ... Cannot dump i. int is not a supported type
dumping s ... Cannot dump s. str is not a supported type
dumping a ... Cannot dump a. Axis is not a supported type
dumping b ... Cannot dump b. Axis is not a supported type
dumping a01 ... Cannot dump a01. LGroup is not a supported type
dumping arr1 ... done
dumping arr2 ... done

Save only some arrays

>>> ses.to_csv('output', names=['arr1'], display=True)                      
dumping arr1 ... done