By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,665 Members | 1,454 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,665 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.