Read and Analyze Giant Files
andu
undo at cloud9.net
Fri Nov 8 00:25:01 EST 2002
--On Thursday, November 07, 2002 18:42:42 -1000 Sannyasin Sivakatirswami
<katir at hindu.org> wrote:
> metacard, 13 lines
>
># !/usr/local/bin/mc
> on startup
> put empty into the_message
> put 0 into the_counter
> read from stdin until empty
> put it into the_message
> repeat for each line this_line in the_message
> if (this_line contains "mystic_mouse") then
> put the_counter + 1 into the_counter
> end if
> end repeat
> put the_counter
> end startup
>
>
>
> is there a more efficient way in Transcript to do this?
>
In Transcript maybe not but you can try metatalk;-).
First of all, I don't understand how you feed the file to the script in
your script (read from stdin until empty?). Since the file is so huge you
should probably use something like:
open file x for read
read from file x at <offset> for <count>
# so that you don't have to load 300MB into ram unless you want to.
# do a
repeat for each line x in it
get offset("mystic_mouse",i)
if it is not 0 then add 1 to the_counter
Just an other possibility... Even better, have the server write a log each
day to keep it shorter (unless it's google;-).
Regards, Andu Novac
More information about the metacard
mailing list