Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How get the Number of Lines from a text file
Message
From
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:
00452187
Views:
67
>>>Let's not squabble. Some good suggestions were made here. Everyone knows that there are nice ways to Sunday to accomplish the same task in VFP. Performance is often negligible between different approaches.
>>
>>Thanks for the new word for me, James :) Now, I didn't intend to squabble. My point was that not all suggestions could be applied to huge files. That's it.
>
>Nadya,
>
>The text file you are talking about would have to be truly huge! In most situations I don't think it would be a problem:
>
>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
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform