473,513 Members | 2,505 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

readlines() with large file raises: IOError: [Errno 12] Cannotallocate memory

Hi there

I am trying to read the content of a really large text file (1GByte) and I get
the following exception if I try to call readlines() on the opened textfile:

IOError: [Errno 12] Cannot allocate memory
This is my code:
INFILE="/home/myuser/myfile"
open_infile = open( INFILE, 'r' )
lines = open_infile.readlines()
Any idea whats going on there?
Does pyhon tries to put the content into machine's RAM (512 MB) which is not big enough so an
exception is raised?

Thanks in advance,
Nico

Arcor-DSL: die echte Flatrate für alle Bandbreiten. Jetzt ohne Einrichtungspreis
einsteigen oder wechseln. Arcor-DSL ist in vielen Anschlussgebieten verfügbar.
http://www.arcor.de/home/redir.php/emf-dsl-1

Jul 18 '05 #1
0 1668

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
10127
by: simon place | last post by:
is the code below meant to produce rubbish?, i had expected an exception. f=file('readme.txt','w') f.write(' ') f.read() ( PythonWin 2.3 (#46, Jul 29 2003, 18:54:32) on win32. ) I got...
9
3188
by: Hans-Joachim Widmaier | last post by:
Hi all. Handling files is an extremely frequent task in programming, so most programming languages have an abstraction of the basic files offered by the underlying operating system. This is...
9
29207
by: wordsender | last post by:
Hey guys, I can't figure this one out, why is this simple script giving me problems? logfile=file(r'test.txt','w') logfile.write('datetime') test=logfile.readlines() When I run it I get...
6
8752
by: haynesc | last post by:
Hi, I'm having a problem where when trying to open a file in write mode, I get an IOError stating no such file or directory. I'm calling an external program which takes an input file and...
17
2832
by: Manlio Perillo | last post by:
Regards. On my system: Python 2.4.1 (#65, Mar 30 2005, 09:13:57) on win32, Windows XP I have this problem: >>> n = 61409 + 1 >>> data = 'x' * n
6
5356
by: VJ | last post by:
Hi All I need to get the user permission of a file using python. I was trying the following code which i found on google grups st = os.stat(myfile) mode = st if mode & stat.ST_IREAD: print...
0
1247
by: Astan Chee | last post by:
Hi everyone, I currently have a problem with reading one of my files. Normally I'd read files like so: overf = 'C:\\overf' my_overf = open(overf,'r') contents = my_overf.readlines()...
5
7658
by: jkn | last post by:
Hi all Python 2.4.2 (#1, Apr 26 2006, 23:35:31) on linux2 Type "help", "copyright", "credits" or "license" for more information. Traceback (most recent call last): File "<stdin>", line 1, in...
4
1833
by: apriebe47 | last post by:
Alright, I realize this is probably very basic to be posted on this newsgroup but I cannot figure out what is causing my problem. Here is the code I am using below: from getpass import getpass ...
0
7161
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7539
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...
1
7101
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
7525
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...
1
5089
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3234
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3222
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1596
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
802
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.