On Fri, Mar 9, 2012 at 7:26 AM, Nicola Creati <ncre...@inogs.it> wrote:
> Hello, > I'm writing a library able to read LAS lidar files. I generally use it > under Linux without any problems. I'm now testing my library on a Windows 7 > 64 bit computer and I meet some problems reading the file. I generally use > fromfile function to read the file. I noted that the fromfile returns an > arry with some zeros at the end if I read the whole file or if i read only > a finite number of data i get only a fraction of them. By the way I have > created a sample script that reproduces the problem I noted: > > """ Sample code """ > import numpy as np > > sz = 1000000 > data = np.random.random(sz) > > output = open('test.bin', 'w') > data.tofile(output) > output.close() > del output > > print 'Original data:', data > > fid = open('test.bin', 'r') > new_data = np.fromfile(fid) > fid.close() > del fid > print 'Data read:', new_data > > fid = open('test.bin', 'r') > slice = np.fromfile(fid, count=100) > fid.close() > print '100 read data:', slice > > > The "new_data" array has several zeros at the end. The "slice" array has > not 100 items. At every code run the "slice" array size changes. > > I'm using numpy 1.6.1 64bit (taken from Christoph Gohlke website) , with > python 2.7.2 64 bit. > Under Linux Ubuntu 10.10 64bit and numpy 1.6.1 the code works as expected. > Thanks. > > Nicola > > Use the binary mode ('wb' and 'rb') when you open the files. Warren > > _______________________________________________ > NumPy-Discussion mailing list > NumPy-Discussion@scipy.org > http://mail.scipy.org/mailman/listinfo/numpy-discussion > >
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion