read from file until a line begins with a certain word

Paul Dupuis paul at researchware.com
Sun Sep 17 06:55:30 EDT 2017


On 9/16/2017 8:50 PM, Matthias Rebbe via use-livecode wrote:
> Hi,
>
> until today i used always put URL to read a complete file into memory. But now i have to process  really large text files with a size of 900 - 1500 MB.
> I know i can read a file until EOF or so.
>
> But how would i read a file until a line that starts with a certain keyword, e.g. mstart. I need to read until the line before that line which starts with mstart.
> And then read from that “mstart” line until the next line before “mstart”.
> Do i have to read line by line and check if the line starts with that keyword or is there also an other way? 
>
> Maybe i am thinking to complicated.
>

Why can you not use the
read from file tFilePath until "mstart"
of
read from {file /pathName/ | stdin} [at /start/] {until {/string/ | end
| EOF | empty} | for /amount/ [/chunkType/]} [in /time/]

If you need to back up to reread the "mstart" string you can then use
Seek to adjust the read position if needed.





More information about the use-livecode mailing list