[Numpy-discussion] Fromfile Issue

Nicola Creati ncreati@inogs...
Fri Mar 9 07:26:18 CST 2012

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')
del output

print 'Original data:', data

fid = open('test.bin', 'r')
new_data = np.fromfile(fid)
del fid
print 'Data read:',  new_data

fid = open('test.bin', 'r')
slice = np.fromfile(fid, count=100)
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.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20120309/b4ae4a72/attachment-0001.html 

More information about the NumPy-Discussion mailing list