Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How get the Number of Lines from a text file
Message
 
 
To
12/12/2000 10:02:32
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00451983
Message ID:
00452203
Views:
81
>>Maximum # of characters per character string or memory variable--16,777,184
>
>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

Yes, in this example should be fgets(). I had 5 mln records text comma-delimited file. I appended to the dbf file with the exact structure. It took about 20-30 minutes to append. No indexes were in this DBF.

I'll try both solutions on this file, to see, that's the fastest approach.

Thanks for ideas.
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform