[Numpy-discussion] converting from scipy.io.fread

Christoph T. Weidemann ctw at cogsci.info
Sun Apr 12 13:43:03 EDT 2009


I noticed that scipy.io.fread is deprecated and wanted to change some
code I got from somebody else accordingly. This code contains
statements like:
fread(fid, 1, 'h')
fread(fid, 1, 'l')
fread(fid, 1, 'd')
fread(fid, 6, 'B')
and variations of those with different number and letters. The
docstring suggested that numpy.fromfile may be a good alternative, but
I'm having some trouble mapping the fread commands to appropriate
fromfile commands. Particularly, I could not figure out how to map the
read_type values (which the fread docstring suggests are PyArray types
-- 'h', however, is not listed as a possible value in the docstring)
to the dtypes in fromfile and how to translate the fread Num variable
into the counts required for fromfile. I would appreciate any help
converting these fread commands to non-deprecated commands (using
fromfile or any other method that may be more appropriate).
Unfortunately I know very little about how exactly the data is stored
in the binary file, so it would be great if the conversion could make
do with the information from the call to fread.



More information about the NumPy-Discussion mailing list