the large file challenge
Richard Gaskin
ambassador at fourthworld.com
Fri Nov 8 21:31:00 EST 2002
Sadhunathan Nadesan wrote:
> #!/usr/local/bin/mc
> on startup
> put "/gig/tmp/log/xaa" into the_file
> put 1 into start_read
> put 0 into the_counter
> put 1 into the_offset
> open file the_file for read
> read from file the_file until eof
> put the num of lines of it into end_read
> close file the_file
> repeat while (start_read < end_read)
> open file the_file for read
> read from file the_file at the_offset for 99 lines
> put it into the_text
> put the number of chars of it + the_offset into the_offset
> repeat for each line this_line in the_text
> if (not eof) then
> if (this_line contains "mystic_mouse") then
> put the_counter + 1 into the_counter
> end if
> end if
> end repeat
> close file the_file
> add 100 to start_read
> end repeat
> put the_counter
> end startup
>
>
> Now, I feel sure we could improve this, fix my errors, etc .... anyone?
I'm confused: if the point is to avoid reading the entire file into memory,
isn't what what line 8 does? And if it's already in memory, why is it read
again inside the loop?
I think I missed something from the original post....
--
Richard Gaskin
Fourth World Media Corporation
Developer of WebMerge 2.0: Publish any database on any site
___________________________________________________________
Ambassador at FourthWorld.com http://www.FourthWorld.com
Tel: 323-225-3717 AIM: FourthWorldInc
More information about the metacard
mailing list