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

2006-06-14 Thread bruno at modulix
Rosario Morgan wrote: > 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') while True: block = file.

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

2006-06-14 Thread Fredrik Lundh
Rune Strand wrote: > Probably a more terse way to do this, but this seems to work > import os > > offset = 0 > grab_size = 6000 > file_size = os.stat('hotels.xml')[6] ouch. why not just loop until f.read returns an empty string ? > f = open('hotels.xml', 'r') > > while offset < file_size: >

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

2006-06-14 Thread Rune Strand
Rosario Morgan wrote: > 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) > newb

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

2006-06-13 Thread Rosario Morgan
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)