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

N

nicogrubert

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top