Python: converting dictionaries into objects with read/write methods

76 Views Asked by At

I need to be able to read/write files using samba connection in Python. For this purpose I use pysmb. However, I am cannot make storeFile function work:

storeFile(service_name, path, file_obj, timeout=30)

Where file_obj – A file-like object that has a read method.

Suppose I have the following dictionary: res={1:np.ones((3,3))}. Locally I would store it with np.save function. Here I tried:

conn.storeFile('BigDataDirectory','data_genkin/2.npz',res)

And got the following error:

`AttributeError: 'dict' object has no attribute 'read'`

Can someone suggest a solution how to convert a dictionary into a file with read method. Similarly, to read a file from samba server I need an output object that has a write method.

Thanks,

Mikhail

0

There are 0 best solutions below