473,401 Members | 2,068 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,401 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 3899
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Jason Murry | last post by:
I have a camera system (Axis) which stores JPG via FTP 1-10fps. There is also a motion jpg live stream. I am trying to store these images either in JPG or in video format so they can be...
2
by: Amy L. | last post by:
Is there a way through .net to read a very large text file (400MB+) backwards line by line. In system.io the filestream class has a "seek" method but the only read method requires you to know how...
8
by: Darsant | last post by:
I'm currently reading 1-n number of binary files, each with 3 different arrays of floats containing about 10,000 values a piece for a total of about 30,000 values per file. I'm looking for a way...
6
by: Rolf Schroedter | last post by:
(Sorry for cross-posting). I need to access large files > 2GByte (Linux, WinXP/NTFS) using the standard C-library calls. Till today I thought I know how to do it, namely for Win32: Use open(),...
4
by: Almad | last post by:
Hello, I wonder how do I create reasonable thumbnails from JPEG with PIL. My code: logging.debug('Downloading image %s' % id) uri = ''.join(, '?p=', str(id)]) uf = urlopen(uri).read() f =...
6
by: Yi Xing | last post by:
Hi, I need to read specific lines of huge text files. Each time, I know exactly which line(s) I want to read. readlines() or readline() in a loop is just too slow. Since different lines have...
2
by: Kevin Ar18 | last post by:
I posted this on the forum, but nobody seems to know the solution: http://python-forum.org/py/viewtopic.php?t=5230 I have a zip file that is several GB in size, and one of the files inside of it...
6
by: =?Utf-8?B?RENX?= | last post by:
Hello all: I have a situation where I need to read a text file containing several million rows (insurance eligibility files). In additional to sequential operations, I also need to support a...
21
by: pilafi | last post by:
Hallo guys!!I have a problem and i would like your help.I have to make a reader for a platform,where reads csv files.So, i made this read and its possible to read now csv files.But the problem is...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.