Re: Line count of a referenced text file?
Re: Line count of a referenced text file?
- Subject: Re: Line count of a referenced text file?
- From: Matthew Broms <email@hidden>
- Date: Tue, 13 Nov 2001 15:21:33 -0400
You're right about EOF Arthur, it's just a property that is simply retrieved
verses actually calculated. Clearly computer files can't have a bunch of
rarely used properties just for our occasional convenience, but I guess I
was hoping that line count might be another gratuitous one.
>
Is something like this really that slow?:
>
>
set opened_file to open for access (choose file)
>
set line_count to 0
>
repeat
>
try
>
read opened_file until return
>
set line_count to line_count + 1
>
on error
>
-- eof
>
exit repeat
>
end try
>
end repeat
>
close access opened_file
>
line_count
Unfortunately yes, when you have 15,773 lines, each being 912 characters in
length. I tried it this way initially and it was dismally slow. I'm
reading in large chunks instead and counting delimiter lists or paragraphs
instead.
Thanks for your suggestions.
Matt