[Numpy-discussion] reading data from file

Hari Sundar hsundar at gmail.com
Fri Aug 19 16:00:03 EDT 2005


I have a small doubt and it is very difficult for me to word this for
google. So maybe someone here can help.

I use the 'fromfile' function to read data directly into arrays. This
works pretty well.

I have a special case, where I am reading in 2 files. The first one is
a full 3D file, (x,y,z). Each location tells me whether data is
available at that location in the other file or not. I call this the
mask.The other file contains information which should sit in x*y*z*D
space, i.e., I have a vector of length D at any given location (x,y,z)
where the mask is not zero.

How do I read this effectively ? I don't want to run a loop and test
for the mask being true and reading in the vector.

Also, I am currently thinking of keeping the information in memory as
an array of shape (x,y,z,D), even though the data is sparse. Is there
a more efficient way to do this ?


More information about the NumPy-Discussion mailing list