Hi, Thanks Alan.
Now I have made changes in code : Present code: *f = open("output.txt")content=f.read().split('\n') f.close()for lines in content:* * <processing>* *content.clear()* Previous code: *f = open("output.txt") content=io.StringIO(f.read()) f.close()for lines in content: <processing>* *content.close()* Now I have found that memory use is roughly 1.5 times the size of text file. Previously it was around 4-5 times. Its remarkable change. Waiting for more suggestions. Thanks, On Mon, Nov 4, 2013 at 5:05 PM, Alan Gauld <alan.ga...@btinternet.com>wrote: > On 04/11/13 11:07, Amal Thomas wrote: > > 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. >> > > So why not use > > > f = open("output.txt") > content=f.read() > f.close() > > And process the file as a raw string? > > Is there a reason for using the StringIO? > > -- > Alan G > Author of the Learn to Program web site > http://www.alan-g.me.uk/ > http://www.flickr.com/photos/alangauldphotos > > _______________________________________________ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor > -- *AMAL THOMASFourth Year Undergraduate Student Department of Biotechnology IIT KHARAGPUR-721302*
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor