Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Record count in txt file
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00796917
Message ID:
00796982
Views:
16
>>>Hey Everyone,
>>>I am trying to get a record count of a txt file without any luck. Does anyone know how to do this? I think I have to use the FGETS() function and count the carriage returns but am not sure how to do this. Any help would be appreciate. Thanks.
>>
>>One simple way to count the records in a big text file when ALINES() mignt not work because of the size is to create a temporary table and suck the file in with APPEND FROM command. Then just get the record count and dump the file. However it may be time consuming.
>>I recently used this method to count the lines in 50Mb text file with ~500,000 lines. It took about 7 sec on PC 1 Ghz, 256 MB RAM
>>
>>
>>CREATE TABLE filecontent (cline c(254))
>>APPEND FROM myfile.TXT TYPE SDF
>>?RECCOUNT()
>>
>
>Hi Nick,
>
>Interesting. Wouldn't it be faster if
CREATE TABLE filecontent (cline c(1))
>?

Yes. It is at least twice as fast, but in the program where I copied the code from, I also needed the content of the file. :)
Nick Neklioudov
Universal Thread Consultant
3 times Microsoft MVP - Visual FoxPro

"I have not failed. I've just found 10,000 ways that don't work." - Thomas Edison
Previous
Reply
Map
View

Click here to load this message in the networking platform