[Numpy-discussion] Question about memmap

Gökhan SEVER gokhansever@gmail....
Wed Jun 10 02:25:47 CDT 2009


On Wed, Jun 10, 2009 at 2:13 AM, Pauli Virtanen <pav@iki.fi> wrote:

> Wed, 10 Jun 2009 01:51:19 -0500, Gökhan SEVER kirjoitti:
> > What's the reason again that memmap only works with binary files?
>
> There are no separate "text files" and "binary files". All files are
> binary, some just contain text that in some cases represents an array of
> numbers.
>
> Memmap views also text files as binary. It returns you an array
> representing the *character data* in the file.
>
> > Could the functionality be extended to text files as well?
>
> In principle, yes. But this would need special parsing of the text in the
> memmap. Doing this right would be considerably more work than just
> representing the binary data. Also, I doubt that this would be very
> useful: representing large amounts of data as text is not efficient. I
> also think few people have interest in this feature.
>

I was expecting to see a similar result to loadtxt() function with memmap().
I just can't map the numbers in to an array but the whole file represented
as characters. Now I see why I don't see what it's actually in my test.txt
in terms of numbers.

Reading more from memmap.py, I see that it uses mmap module. Your
explanations confirm my observation that text files should also work here
--providing that missing special parsing. I don't have much idea of how to
implement this...

Gokhan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20090610/dcb89445/attachment.html 


More information about the Numpy-discussion mailing list