On Jul 22, 2:05 am, Uwe Schmitt <[EMAIL PROTECTED]> wrote: > jadamwil schrieb: > > > > > Hello, > > I am using the numpy fromfile function to read binary data from a file > > on disk. The problem is that the program runs fine on a Mac, but gives > > an error or warning on windows when trying to read the data. I use it > > like this: > > > Signal = zeros((N, 16), dtype=float32) > > for sample in range(0, N): > > # this function gets the next position in the file to seek to > > s = getFilePos(sample) > > > # go to the correct location in the file; this IS checked to make > > sure it is within the file > > mFile.seek(s) > > > # read the 16 float32 values from the file > > D = fromfile(mFile, dtype=numpy.float32, 16) > > > # save D in Signal > > Signal[sample, :] = D > > > This will fail when sample is ~4. If I change the range to (5,N), > > skipping the "bad" file location, it will run fine for a few samples, > > and then give another error. The message it gives is: > > "16 items requested but only 7 read" > > > So D is a 7x1 vector, and the program dies when it tries to assign D > > to the slice of Signal ("ValueError: shape mismatch: objects cannot be > > broadcast to a single shape"). > > > On windows, the Python version is 2.5.2, and the most recent numpy and > > scipy are being used as well. I tried using Enthought, but it gave > > this error as well, in addition to a c runtime error whenever I > > imported scipy (which is another post topic...). > > > Any ideas on what might be causing this? Is there a way to debug the > > fromfile function? And, remember, this works perfectly on a Mac. Would > > compiling everything (python, scipy, numpy) potentially solve this? > > Did you open the file in binary mode ? > > Greetings, Uwe
Yes I did. Would that make a difference between a mac and windows? Thanks -- http://mail.python.org/mailman/listinfo/python-list