By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,282 Members | 1,314 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,282 IT Pros & Developers. It's quick & easy.

accessing parts of large files with File.seek()

P: n/a
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

Aug 8 '07 #1
Share this Question
Share on Google+
2 Replies

P: n/a
On Aug 8, 11:46 am, "mhearne808[insert-at-sign-here]gmail[insert-dot-
here]com" <mhearne...@gmail.comwrote:
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@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@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

Aug 9 '07 #2

P: n/a
On Aug 8, 7:37 pm, "programmer...@gmail.com" <programmer...@gmail.com>
wrote:
On Aug 8, 11:46 am, "mhearne808[insert-at-sign-here]gmail[insert-dot-

here]com" <mhearne...@gmail.comwrote:
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@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@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
I think I've figured out what the problem must be (not at Mac anymore,
so will have to test tomorrow). According to this link:
http://docs.python.org/lib/posix-large-files.html

I probably need to compile in large file support on my Mac. I get it
for free on my Ubuntu linux box...

FYI, it was an OverFlow Error.

Aug 9 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.