472,114 Members | 2,179 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,114 software developers and data experts.

accessing parts of large files with File.seek()

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
2 3807
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
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.

Similar topics

4 posts views Thread by Jason Murry | last post: by
6 posts views Thread by Rolf Schroedter | last post: by
4 posts views Thread by Almad | last post: by
2 posts views Thread by Kevin Ar18 | last post: by
6 posts views Thread by =?Utf-8?B?RENX?= | last post: by
21 posts views Thread by pilafi | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.