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

Author: Gianni Turri

Posted: 2017-04-21 at 10:02:23

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

--

Gianni

_______________________________________________

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/l27kfc58h4400rk01811jbgnifgtegbr4q@4ax.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 Gianni Turri