I have a compressed HDF file (HDF.Z) and would like to open it like that:
from subprocess import Popen, PIPE
f = Popen(['zcat', 'myfile.HDF.Z'], stdout=PIPE).stdout
In order to get the data I need to use pyhdf:
from pyhdf.SD import SD, SDC
mydata = SD(f, SDC.READ)
However, this results in an error message:
*** TypeError: coercing to Unicode: need string or buffer, file found
Is there a way to open this file as a buffer to read it in? Btw: what is a buffer?
At a short glance, I found no way to make it access an open stream.
You can do the following:
SD()
.Another option is very system dependent: you could take the file handle and do
bit this is very platform-dependent (Linux only) and, if
SD()
doesmmap()
by any chance, it will fail.