Re: Faster method needed - reading text files stored on local network file server
by Marco van de Voort <marcov@[EMAIL PROTECTED]
>
Feb 22, 2008 at 10:14 AM
On 2008-02-22, Rob Kennedy <me3@[EMAIL PROTECTED]
> wrote:
>
> LoadFromFile necessarily loads the entire file. Does it work any faster
> if you don't read the whole file? How fast does "cat" work in comparison
> to "head -n5"?
>
> AssignFile(F, FileName);
> Reset(F);
> try
> Readln(F, readOneLine); // read and discard first line
> Readln(F, readOneLine); // read and discard second line
> for i := 3 to 5 do begin
> Readln(F, readOneLine);
> // Do something with this line
> end;
> finally
> CloseFile(F);
> end;
And maybe a filemode to avoid any lock? From memory, getting the lock is
sometimes the costliest operation on a network drive.
In general characterisation of what is the cause of the problem (latency
or
throughput) is also a good one.