accessing parts of large files with File.seek()

programmer.py at gmail.com programmer.py at gmail.com
Wed Aug 8 21:37:32 EDT 2007


On Aug 8, 11:46 am, "mhearne808[insert-at-sign-here]gmail[insert-dot-
here]com" <mhearne... at gmail.com> wrote:
> I'm having a problem with the File object's seek() method.
> Specifically, I cannot use it to seek to a location in a binary file
> that is greater than 2^31 (2147483648).  This seems unnecessarily
> limiting, as it is common these days to have files larger than 2 GB.
>
> Is there some LargeFile object out there that I can use to read my
> file, which is approximately 3.3 GB in size?
>
> Python version (freshly built from source this morning):
> Python 2.5.1 (r251:54863, Aug  8 2007, 09:23:05)
> [GCC 4.0.1 (Apple Computer, Inc. build 5363)] on darwin
>
> Thanks,
>
> Mike

I use large files quite a bit, but in Windows & Linux.  Here's a quick
excerpt of a local ubuntu-linux session...

jaime at elizabeth:/var/virtualbox/VDI$ ls -l
total 1682536
-rw-rwx--- 1 jaime vboxusers      40960 2007-07-20 21:41 windows
xp.vdi
-rw-rwx--- 1 jaime vboxusers 3591387136 2007-07-20 21:53 winxp.vdi
jaime at elizabeth:/var/virtualbox/VDI$ ipython
Python 2.5.1 (r251:54863, May  2 2007, 16:27:44)
Type "copyright", "credits" or "license" for more information.

IPython 0.7.3 -- An enhanced Interactive Python.
?       -> Introduction to IPython's features.
%magic  -> Information about IPython's 'magic' % functions.
help    -> Python's own help system.
object? -> Details about 'object'. ?object also works, ?? prints more.

In [1]: f = file('winxp.vdi')

In [2]: f.seek(3591387132)

In [3]: f.read()
Out[3]: '\x00\x00\x00\x00'

In [4]:

What exception are you receiving?  (Not that I can offer any advice,
as I don't have a Mac to use for testing.)...

jw




More information about the Python-list mailing list