>>>James,
>>>(not intending any squabble - .2 cents addition:)
>>>In a previous reply I saw fread() to count lines.
>>>Real problem with fread() it should be done byte by byte. The code I saw would error on first call to fread. fgets() could be used but it has a bug (cannot handle lines > 8192chars - maybe fixed in SP4?) OTOH for huge files (>1 billion lines < bg >) lowlevel sounds to be the only way (for >2Gb files I don't have an idea what OS response would be).
>>>IMHO Barbara's original reply is the best with a slight modification (so it's faster than array approach too):
>>>
>>>
create cursor dummy (f1 l)
>>>append from (lcFile) type sdf
>>>nLines = reccount()
>>>use in 'dummy'
>>>Best regards
>>>Cetin
>>
>>Hi Cetin,
>>
>>I have a 382MB file. Dummy approach took 303.768 sec. Fgets approach took forever. I was not patient enough to wait, so I kill VFP. Right now I decide to repeat this test, this case with fgets(lnHandle,1). Seems to hang up also...
>>
>>Therefore your and David's approach is the fastest.
>
>Nadya,
>
>fgets(lnHandle,1) would read 1 bit at a time. That's why it is slow. fgets without the extra parameter would read the line until a carriage return is encountered. Actually this approach is ver fast, if you know you line won't exceed the 8,192 char limit.
Yes, I understood that already. First time I tried fgets(lnHandle,2000). Now I'm trying fgets(lnHandle) (e.g. without second parameter). Let's see, how long would it be.
Have you already made few tests?
If it's not broken, fix it until it is.
My Blog