Closed talenz closed 8 months ago
I don’t really know numpy but how do you do it with a local file? What’s the error that you get with the example code you’ve shared.
With a local file, just use numpy.load("tmp.npy")
The Error is
array = numpy.fromfile(fp, dtype=dtype, count=count) io.UnsupportedOperation: fileno
I don’t really know numpy but how do you do it with a local file? What’s the error that you get with the example code you’ve shared.
This works~ `from smbclient._io import ( SMBDirectoryIO, SMBFileIO, SMBFileTransaction, SMBPipeIO, SMBRawIO, ioctl_request, query_info, set_info, )
smbclient.register_session("10.10.50.1")
file_class = { "file": SMBFileIO, "dir": SMBDirectoryIO, "pipe": SMBPipeIO, }["file"]
raw_fd = file_class( r"\10.10.50.1\tmp.np", mode="rb", share_access=None, desired_access=None, file_attributes=None, )
raw_fd.open() x = np.load(raw_fd)`
You can avoid all that extra work by just opening the raw
smb_file by turning off buffering
import smbclient
with smbclient.open_file(r'\\server\share\file.tmp', mode='rb', buffering=0) as fd:
np.load(fd)
Take "\10.10.50.1\tmp.np" as a example.
with smbclient.open_file(r"\\10.10.50.1\tmp.np", mode='rb') as fl: x = np.load(fl, allow_pickle=True)
Not Working!!