Looping through a file a block of text at a time not by line

Rosario Morgan rosario_morgan at yahoo.com
Wed Jun 14 01:14:31 EDT 2006


Hello

Help is great appreciated in advance.

I need to loop through a file 6000 bytes at a time.  I was going to 
use the following but do not know how to advance through the file 6000 
bytes at a time.

file = open('hotels.xml')
block = file.read(6000)                                             
newblock = re.sub(re.compile(r'<Rate.*?></Rate>'),'',block)
print newblock

I cannot use readlines because the file is 138MB all on one line.

Suggestions?

-Rosario






More information about the Python-list mailing list