Re: Getting count of rows in a text file -- best approach?

Author: mbsoftwaresolutions@mbsoftwaresolutions.com

Posted: 2017-04-21 at 13:34:18

On 2017-04-21 11:27, Gianni Turri wrote:

> On Fri, 21 Apr 2017 17:02:23 +0200, Gianni Turri <giannit62@gmail.com>

> wrote:

>

>> On Fri, 21 Apr 2017 10:44:34 -0400,

>> mbsoftwaresolutions@mbsoftwaresolutions.com wrote:

>>

>>> VF9SP2

>>>

>>> Currently, I'm simply doing this for now:

>>>

>>> RowCount = OCCURS(CHR(13),FILETOSTR(m.Filename))

>>>

>>> Is there a better (read: FASTER) way? These are tab delimited text

>>> files so I can't really use FSEEK or FSIZE(m.Filename) (which

>>> requires

>>> SET COMPATIBLE ON) because I can't be sure of each record's length.

>>

>> Hi Mike,

>>

>> I have never used fsize this way, I always use fseek to calculate

>> files size.

>>

>> m.handle = fopen(m.Filename, 0)

>> m.size = fseek(m.handle, 0, 2)

>> fclose(m.handle)

>>

>> To answer your question, try this:

>>

>> create cursor TMP_CURSOR (DUMMY Character (1))

>>

>> append from (m.Filename) sdf

>>

>> m.RowCount = reccount() +1

>>

>> USE in TMP_CURSOR

>>

>> ? m.RowCount

>

> May be you must use only reccount() instead of reccount() +1.

Ok now I get your approach. Cool trick. I tried it. In testing, it

actually wasn't any faster than the OCCURS approach. But thanks for the

response though!

_______________________________________________

Post Messages to: ProFox@leafe.com

Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox

OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech

Searchable Archive: http://leafe.com/archives/search/profox

This message: http://leafe.com/archives/byMID/profox/b8d916da69790690cb0db19e4033d9ad@mbsoftwaresolutions.com

** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.

©2017 mbsoftwaresolutions@mbsoftwaresolutions.com