Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How get the Number of Lines from a text file
Message
 
 
À
11/12/2000 21:59:23
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00451983
Message ID:
00452008
Vues:
54
>>>>HI all!!
>>>>
>>>>I wonder if someone has an specific technique to get the number of lines from a text file...
>>>>
>>>>thanks
>>>
>>>create cursor Dummy (TxtFld C (250))
>>>append from TextFile SDF
>>>nLines = Reccount()
>>>
>>
>>Thanks !!
>>Very clever!
>>
>
>Low level file reads might be faster:
>
>LOCAL lnHandle, lnCount
>
>*-----------------------------------------
>*-- Get a file handle
>*-----------------------------------------
>lnhandle = FOPEN("myFile.txt")
>
>*-----------------------------------------
>*-- Move to the first line
>*-----------------------------------------
>=FSEEK(lnhandle, 0, 0)
>
>*-----------------------------------------
>*-- Loop through each line and count
>*-----------------------------------------
>lnCount = 0
>
>DO WHILE !FEOF()
>  lnCount = lnCount + 1
>  =FREAD(lnHandle)
>ENDDO
>
>RETURN lnCount
Yes, I was going to suggest it too. Besides, this is the only way for really big files (more than 16MB).
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform