Reading/Deleting Last Line Of File

Jeff Massung massung at gmail.com
Thu Feb 11 00:13:10 EST 2010


Warren,

I've read through most of these suggestions, but I'm surprised that the
obvious hasn't been suggested yet (that I've seen): skip everything...

put the length of url "file:myfile.txt" into tEnd
open file "myfile.txt" for text update
seek to tEnd in file "myfile.txt"

>From here just back up a "reasonable" number of characters... say 200. Find
the last CR character, nuke everything else and close the file. Didn't find
one? Try backing up another 200, etc. It'll be a whole lot faster.

Edge case to concern yourself with would be if your file happens to end with
a CR and maybe you want to ignore those cases. But that should be easy
enough to solve.

HTH,

Jeff M.

On Wed, Feb 10, 2010 at 7:06 AM, Warren Kuhl <warrenkuhl at gmail.com> wrote:

> Thanks for all the suggestions.  I will look into trying some of them
> to see what works best for me.  The file currently contains
> 105,750,304 records.
>
> I will report back my findings.
>
> Thanks,
> Warren
>
>



More information about the Use-livecode mailing list