Reading a (BIG) text file one line at a time

MisterX b.xavier at internet.lu
Tue Nov 23 00:23:48 EST 2004


I have a freeware stack with all the read and write files examples with
buffered reading and buffer block positioning/navigation included... There's
also more features like file info, hex or text display among others...

This is much much faster than reading line by line and wont abuse RAM...

Unfortunately, all my development is blocked by bug 2431. If you vote for
it, I will make this stack available again tonite. 

cheers
Xavier, still blocked
--


> -----Original Message-----
> From: use-revolution-bounces at lists.runrev.com 
> [mailto:use-revolution-bounces at lists.runrev.com] On Behalf Of 
> Gordon Tillman
> Sent: Monday, November 22, 2004 21:14
> To: Rob Beynon; How to use Revolution
> Subject: Re: Reading a (BIG) text file one line at a time
> 
> Hi Rob,
> 
> On Nov 22, 2004, at 14:05, Rob Beynon wrote:
> 
> > Greetings all,
> > I have failed to discover how to read a file one line at a 
> time. The 
> > file is a text file, and is large (84MB) but I need to 
> process it on a 
> > line by line basis, rather than read the whole file into a 
> field (not 
> > even sure I can!).
> >
> > I thought of
> >
> > read from myFile until EOF for one line
> >
> > but that doesn't work
> >
> > Help would be greatly appreciated here! Would you be good enough to 
> > mail to my work address, as I have yet to work out how to 
> access the 
> > list effectively
> 
> Once you open your file you can use:
> 
> read from file "your_file" for 1 line
> 
> The line that is read is put into the "it" variable When you 
> hit the end of the file then "the result" will no longer be 
> empty.  It will have "eof" in it.
> 
> For example, assuming the file tFile is open:
> 
> repeat forever
>      read from file tFile for 1 line
>      put it into tLine
>      put the result into tRes
> 
>      if tRes is not empty then exit repeat
> 
>      -- do something with tLine
> end repeat
> 
> close file tFile
> 
> 
> --gordon
> 
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution
> 



More information about the use-livecode mailing list