By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,728 Members | 2,462 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,728 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:
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,

Arcor-DSL: die echte Flatrate für alle Bandbreiten. Jetzt ohne Einrichtungspreis
einsteigen oder wechseln. Arcor-DSL ist in vielen Anschlussgebieten verfügbar.

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.