[Tutor] Load Entire File into memory

Amal Thomas amalthomas111 at gmail.com
Mon Nov 4 12:07:17 CET 2013


Hi,

 I am new to python. I am working in computational biology and I have to
deal with text files of huge size. I know how to read line by line from a
text file. I want to know the best method in  *python3* to load the enire
file into ram and do the operations.(since this saves time)
  I am currently using this method to load my text file:


*f = open("output.txt")content=io.StringIO(f.read())f.close()*
 But I have found that this method uses 4 times the size of text file.( if
output.txt is 1 gb total ram usage of the code is approx 3.5 gb :( ).
Kindly suggest me a better way to do this.

Working on
Python 3.3.1,ubuntu 13.04(Linux  3.8.0-29-generic x64)

Thanks

-- 


*AMAL THOMAS *
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20131104/5d956209/attachment.html>


More information about the Tutor mailing list