我的python代码正在接收一个表示hdf5文件字节的字节数组。
我想将这个字节数组读取到内存中的h5py文件对象,而无需先将字节数组写入磁盘。 这个页面说我可以打开一个内存映射文件,但它会是一个新的空文件。 我想从字节数组转到内存中的hdf5文件,使用它,放弃它,不要在任何时候写入磁盘。
是否可以用h5py来做到这一点? (或使用C的hdf5,如果这是唯一的方法)
My python code is receiving a byte array which represents the bytes of the hdf5 file.
I'd like to read this byte array to an in-memory h5py file object without first writing the byte array to disk. This page says that I can open a memory mapped file, but it would be a new, empty file. I want to go from byte array to in-memory hdf5 file, use it, discard it and not to write to disk at any point.
Is it possible to do this with h5py? (or with hdf5 using C if that is the only way)
最满意答案
您可以尝试使用Binary I / O创建一个File对象并通过h5py读取它:
f = io.BytesIO(YOUR_H5PY_STREAM) h = h5py.File(f,'r')You could try to use Binary I/O to create a File object and read it via h5py:
f = io.BytesIO(YOUR_H5PY_STREAM) h = h5py.File(f,'r')更多推荐
发布评论