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

nicogrubert at arcor.de nicogrubert at arcor.de
Mon Nov 22 04:06:24 EST 2004


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




More information about the Python-list mailing list