Re: [Numpy-discussion] Reading from binary file with memmap, with offset

2013-10-10 Thread Andreas Hilboll
On 10.10.2013 15:07, Joe Kington wrote: > You just need to supply the "offset" kwarg to "memmap". > > for example: > > with open(localfile, "r") as fd: > # read offset from first line of file > offset = int(next(fd).split()[-2]) > np.memmap(fd, dtype="float32", mode="r", offset=offset) > >

Re: [Numpy-discussion] Reading from binary file with memmap, with offset

2013-10-10 Thread Andreas Hilboll
On 10.10.2013 14:57, Julian Taylor wrote: > you have to use the offset keyword argument of np.memmap, else it will > always start from the beginning of the file > np.memmap(fd, dtype="float32", mode="r", offset=offset) Thanks for that! I just proposed an update to the memmap docstring to bet

Re: [Numpy-discussion] Reading from binary file with memmap, with offset

2013-10-10 Thread Joe Kington
You just need to supply the "offset" kwarg to "memmap". for example: with open(localfile, "r") as fd: # read offset from first line of file offset = int(next(fd).split()[-2]) np.memmap(fd, dtype="float32", mode="r", offset=offset) Also, there's no need to do things like "offset = int(fd.re

Re: [Numpy-discussion] Reading from binary file with memmap, with offset

2013-10-10 Thread Julian Taylor
you have to use the offset keyword argument of np.memmap, else it will always start from the beginning of the file >>> np.memmap(fd, dtype="float32", mode="r", offset=offset) On Thu, Oct 10, 2013 at 2:43 PM, Andreas Hilboll wrote: > Hi, > > I have a problem using memmap correctly. I need to re

[Numpy-discussion] Reading from binary file with memmap, with offset

2013-10-10 Thread Andreas Hilboll
Hi, I have a problem using memmap correctly. I need to read a data file which consists of an ASCII header and appended binary single precision floating point values. memmap complains that the "Size of available data is not a multiple of the data-type size." But as far as I can tell, the size *doas