[SciPy-user] partially reading a file...
Travis E. Oliphant
oliphant at enthought.com
Wed Aug 6 14:14:35 EDT 2008
fred wrote:
> Travis E. Oliphant a écrit :
>
>
>> Absolutely memory mapping still applies --- it's a perfect application
>> for it. But, you will probably need a 64-bit system.
>>
> No problem.
>
>
>> Memory mapping is how the OS handles "virtual memory" which uses disk
>> space to increase main memory. You are just using that idea directly
>> with a memory mapped file.
>>
> Ok.
> Thanks for the hint.
>
>
More directly:
Use numpy.memmap --- look at the docstring for example use and help on
all the arguments available. But, something like this (untested):
a = numpy.memmap(<filename>, mode='r', dtype=float, shape=(nx,ny,nz))
b = a[:nx/4,:ny/4,:nz/4]
b.tofile(<somefilename>)
Should work...
-Travis
More information about the SciPy-User
mailing list