Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How get the Number of Lines from a text file
Message
 
 
À
12/12/2000 10:02:32
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00451983
Message ID:
00452248
Vues:
76
>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) && Smallest possible to speed up
>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.
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