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

2017-05-02 Thread Thierry Nivelet
I answered to 'not documented'

Of course filetostr() works as it does not go through a variable.

Question vastly discussed on AtoutFox. 

Var = "16 MB string"
Var = m.var + 'n' && bingo

Thierry Nivelet
http://foxincloud.com/
Give your VFP app a second life in the cloud

> Le 2 mai 2017 à 12:43, Ted Roche  a écrit :
> 
> It is true and yet it is not. Rick Strahl wrote an article showing
> there are things you can do (and not do) with HUUGE files read in
> using FileToStr():
> 
> https://www.west-wind.com/wconnect/weblog/ShowEntry.blog?id=882
> 
> Since the Original Poster (anyone remember him :)?) was only
> performing read-only functions on the file once read in, this should
> work.
> 
> 
> 
>> On Tue, May 2, 2017 at 5:57 AM, Thierry Nivelet  
>> wrote:
>> Mentioned in "Visual Foxpro system capacities"
>> 
>> Thierry Nivelet
>> http://foxincloud.com/
>> Give your VFP app a second life in the cloud
>> 
>> Le 1 mai 2017 à 23:20, mbsoftwaresoluti...@mbsoftwaresolutions.com a écrit :
>> 
 the help file does
 say a 16MB limit on memory variables
>> 
>> 
[excessive quoting removed by server]

___
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/4390c4ad-842b-4be3-a0ae-28acc63a3...@foxincloud.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.

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

2017-05-02 Thread mbsoftwaresolutions

On 2017-05-02 10:23, Stephen Russell wrote:
Ok, who else chuckled when the database guy doesn't use data to get a 
count

but is going to count text file lines instead?

Seriously I found that funny.




It's all a matter of where you're doing the processing!  Up front BEFORE 
you load it, showing the user "here are the files you need to load yet" 
or after the fact (and of course after it's loaded, this exercise is 
moot).



___
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/efc127d35ab63871bb73cdc6597ae...@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.


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

2017-05-02 Thread mbsoftwaresolutions

On 2017-05-02 06:43, Ted Roche wrote:

It is true and yet it is not. Rick Strahl wrote an article showing
there are things you can do (and not do) with HUUGE files read in
using FileToStr():

https://www.west-wind.com/wconnect/weblog/ShowEntry.blog?id=882

Since the Original Poster (anyone remember him :)?) was only
performing read-only functions on the file once read in, this should
work.



Excellent...thanks, Ted.  Yes, FILETOSTR(..) worked for me.  (And yes, I 
was the original poster.  lol)


___
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/98964c26a17b8cbfcf34b078bc8b0...@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.


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

2017-05-02 Thread Stephen Russell
Ok, who else chuckled when the database guy doesn't use data to get a count
but is going to count text file lines instead?

Seriously I found that funny.

On Tue, May 2, 2017 at 9:18 AM,  wrote:

> On 2017-05-02 05:57, Thierry Nivelet wrote:
>
>> Mentioned in "Visual Foxpro system capacities"
>>
>
>
> Yes but as Fred said, it looks like you can load greater than 16 MB.  I
> could swear I did.
>
[excessive quoting removed by server]

___
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/cajidmyjma2c--rr-akpephbzdknwszxaon20kwsezm_cvbt...@mail.gmail.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.


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

2017-05-02 Thread mbsoftwaresolutions

On 2017-05-02 05:57, Thierry Nivelet wrote:

Mentioned in "Visual Foxpro system capacities"



Yes but as Fred said, it looks like you can load greater than 16 MB.  I 
could swear I did.


___
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/ad149f8128e5db78dd008e763d830...@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.


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

2017-05-02 Thread Ted Roche
It is true and yet it is not. Rick Strahl wrote an article showing
there are things you can do (and not do) with HUUGE files read in
using FileToStr():

https://www.west-wind.com/wconnect/weblog/ShowEntry.blog?id=882

Since the Original Poster (anyone remember him :)?) was only
performing read-only functions on the file once read in, this should
work.



On Tue, May 2, 2017 at 5:57 AM, Thierry Nivelet  wrote:
> Mentioned in "Visual Foxpro system capacities"
>
> Thierry Nivelet
> http://foxincloud.com/
> Give your VFP app a second life in the cloud
>
> Le 1 mai 2017 à 23:20, mbsoftwaresoluti...@mbsoftwaresolutions.com a écrit :
>
>>> the help file does
>>> say a 16MB limit on memory variables
>
>
[excessive quoting removed by server]

___
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/cacw6n4sqru069eje5wlqrjk9o0syzldpdrv2bxmxomq0dix...@mail.gmail.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.

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

2017-05-02 Thread Thierry Nivelet
Mentioned in "Visual Foxpro system capacities"

Thierry Nivelet
http://foxincloud.com/
Give your VFP app a second life in the cloud

Le 1 mai 2017 à 23:20, mbsoftwaresoluti...@mbsoftwaresolutions.com a écrit :

>> the help file does
>> say a 16MB limit on memory variables


___
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/6ca69c44-7485-40fd-85b3-895dadc82...@foxincloud.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.

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

2017-05-01 Thread mbsoftwaresolutions

On 2017-04-26 16:05, Fred Taylor wrote:
Sure looks like you can load larger than 16MB.  Though the help file 
does

say a 16MB limit on memory variables.

Fred



Perhaps the Help file is outdated?  That guy from the Fox team must have 
been let go before he could update it.  


___
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/c91f19ba124390f8137edc48161bc...@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.


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

2017-05-01 Thread mbsoftwaresolutions

On 2017-04-29 06:50, Laurie Alvey wrote:

Hi All,

This is all very ingenious, but I am curious to know why you would want 
to

know the number of lines.

Laurie



As the original poster, I'll answer:  we want to compare the # of 
records sent this year compared to what they sent us last year.  I was 
looking on the raw text file side initially; I believe I've changed my 
focus though and am looking at the table count after importing into SQL 
Server instead now.  But this thread was good to learn of other options!


___
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/cd6911385300ae290401d38bca61d...@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.


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

2017-05-01 Thread Stephen Russell
It is real easy in Powershell.

https://blogs.technet.microsoft.com/heyscriptingguy/2011/10/09/use-a-powershell-cmdlet-to-count-files-words-and-lines/



On Sat, Apr 29, 2017 at 5:50 AM, Laurie Alvey <trukke...@gmail.com> wrote:

> Hi All,
>
> This is all very ingenious, but I am curious to know why you would want to
> know the number of lines.
>
> Laurie
>
> On 29 April 2017 at 01:20, Darren <fox...@ozemail.com.au> wrote:
>
> > Gianni
> >
> > The approach I took for .NET was ...  (And this is the first time I have
> > done this so was a bit of a learning exercise) Again   very likely
> > better ways to achieve this.
> >
> > Create a .NET DLL and use in VFP.
> >
> > Primary reference here:  http://www.tek-tips.com/faqs.cfm?fid=3836  (bit
> > out of date)
> >
> > 1.  Using Visual Studio .NET create a C# Class Library project –
> named
> > Utilities
> > 2.  Add reference to “System.EnterpriseServices”
> > 3.  Code the Class e.g.
> > using System;
> > using System.Text;
> > using System.Linq;
> > using System.Runtime.InteropServices;
> > using System.Collections.Generic;
> > using System.Threading.Tasks;
> >
> > namespace Utilities {
> > public class FileInfo :  System.EnterpriseServices.ServicedComponent
> {
> > public Int32 LineCount(String FilePath)
> > {
> > int count = System.IO.File.ReadLines(FilePath).Count() ;
> > return count;
> > }
> > }
> > }
> >
> > 4.  Create key pair (To sign the assembly).  In my case I used (from
> > an Admin command window):
> >
> > CD “c:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin>”
> > sn -k Utilities.SNK
> >
> > Returned:
> >
> > Microsoft (R) .NET Framework Strong Name Utility  Version 3.5.30729.1
> > Copyright (c) Microsoft Corporation.  All rights reserved.
> >
> > Key pair written to Utilities.SNK
> >
> > 5.  Copy the SNK file to the DLL build directory.
> >
> > 6.  Edit Assembly.cs file.
> >
> > Change the entry [assembly: ComVisible(false)] to [assembly:
> > ComVisible(true)]
> >
> > Ignore the [assembly: AssemblyKeyFile("")] step in Craig’s tip.  Instead
> > add the SNK file in the “Signing” section per step 7.
> > 7.  Under properties of the project select “Signing”
> > •   Check “Sign the assembly”
> > •   Type in the “Key File name:” in this case Utilities.SNK
> > •   I de-selected “Protect my key file with a password” – too many to
> > remember already.
> > 8.  Build the Solution in Visual Studio
> >
> > 9.  Register the assembly. (from Admin command prompt)
> >
> > CD “C:\Windows\Microsoft.NET\Framework\v4.0.30319”
> > regasm.exe D:\VFP9\apps\c#\Utilities\Utilities\bin\Release\Utilities.dll
> > /tlb /nologo /codebase
> >
> > Returned:
> > Types registered successfully
> > Assembly exported to 'D:\VFP9\apps\c#\Utilities\Utilities\bin\Release\
> > Utilities.tlb’,
> > and the type library was registered successfully
> >
> > C:\Windows\Microsoft.NET\Framework\v4.0.30319>
> >
> > 10. Then to use it in VFP ..
> >
> > oUtil = CREATEOBJECT("Utilities.FileInfo")
> > nLines = oUtil.LineCount()
> >
> > -Original Message-
> > From: ProfoxTech [mailto:profoxtech-boun...@leafe.com] On Behalf Of
> > Gianni Turri
> > Sent: Saturday, 29 April 2017 2:24 AM
> > To: profoxt...@leafe.com
> > Subject: Re: Getting count of rows in a text file -- best approach?
> >
> > Test file of 1.67 GB correctly managed by FSO but not by VFP9 SP2 that
> > gives Error 43 (There is not enough memory to complete this operation).
> >
> > Test file of 5.31 GB correctly managed by FSO but not by VFP9 SP2 that
> > gives Error 1103 (Invalid seek offset).
> >
> > FSO method counts chr(10) / LF characters.
> >
> > alines() by default counts the occurrences of chr(10) plus the
> occurrences
> > of chr(13) minus the occurrences of chr(13) + chr(10)
> >
> > Please tell us more about the FLL and the code you used!
> >
> > Gianni
> >
> > On Sat, 29 Apr 2017 01:15:06 +1000, "Darren" <fox...@ozemail.com.au>
> > wrote:
> >
> > Many ways to do this.  I've compared 3.
> >
> > With a text file 350Mb | 5.3Million lines . Each method reported same #
> of
> > lines.
> >
> > Timing done with high resolution timers so reasonably accurate. ...
&g

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

2017-05-01 Thread Michael Madigan
Create a dummy database with one field
append from text.txt  delimited
go bottomnumberoflines = recno()



  From: "mbsoftwaresoluti...@mbsoftwaresolutions.com" 

 To: ProFox  
 Sent: Friday, April 21, 2017 10:45 AM
 Subject: Getting count of rows in a text file -- best approach?
   
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.

tia,
--Mike


[excessive quoting removed by server]

___
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/319186728.1340818.1493625928...@mail.yahoo.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.

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

2017-04-29 Thread Darren
Laurie

For me my goto has been C++ and FLL whenever I want something more performant 
and I have always been a huge fan using the Windows API and all it has to offer 
as well as other extensions that the fox is so good at consuming. 

Recently I have been getting more familiar with .NET (and I do like it to be 
honest) so I thought  here's an opportunity to do something quickly using the 
resources and .NET and work out how to get that to work with VFP. So for me it 
wasn’t about counting lines but rather about how to get to use .NET in VFP (and 
I am aware of things like wwwDotNetBridge but I wanted to get a bit of a more 
in depth understanding of what is going on, hence the approach I took.)

I think the original post was to ascertain the best way to do it with large 
files. It grew from there.

Cheers





-Original Message-
From: ProfoxTech [mailto:profoxtech-boun...@leafe.com] On Behalf Of Laurie Alvey
Sent: Saturday, 29 April 2017 8:51 PM
To: profoxt...@leafe.com
Subject: Re: Getting count of rows in a text file -- best approach?

Hi All,

This is all very ingenious, but I am curious to know why you would want to know 
the number of lines.

Laurie

On 29 April 2017 at 01:20, Darren <fox...@ozemail.com.au> wrote:

> Gianni
>
> The approach I took for .NET was ...  (And this is the first time I 
> have done this so was a bit of a learning exercise) Again   very 
> likely better ways to achieve this.
>
> Create a .NET DLL and use in VFP.
>
> Primary reference here:  http://www.tek-tips.com/faqs.cfm?fid=3836  
> (bit out of date)
>
> 1.  Using Visual Studio .NET create a C# Class Library project – named
> Utilities
> 2.  Add reference to “System.EnterpriseServices”
> 3.  Code the Class e.g.
> using System;
> using System.Text;
> using System.Linq;
> using System.Runtime.InteropServices;
> using System.Collections.Generic;
> using System.Threading.Tasks;
>
> namespace Utilities {
> public class FileInfo :  System.EnterpriseServices.ServicedComponent {
> public Int32 LineCount(String FilePath)
> {
> int count = System.IO.File.ReadLines(FilePath).Count() ;
> return count;
> }
> }
> }
>
> 4.  Create key pair (To sign the assembly).  In my case I used (from
> an Admin command window):
>
> CD “c:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin>”
> sn -k Utilities.SNK
>
> Returned:
>
> Microsoft (R) .NET Framework Strong Name Utility  Version 3.5.30729.1 
> Copyright (c) Microsoft Corporation.  All rights reserved.
>
> Key pair written to Utilities.SNK
>
> 5.  Copy the SNK file to the DLL build directory.
>
> 6.  Edit Assembly.cs file.
>
> Change the entry [assembly: ComVisible(false)] to [assembly:
> ComVisible(true)]
>
> Ignore the [assembly: AssemblyKeyFile("")] step in Craig’s tip.  
> Instead add the SNK file in the “Signing” section per step 7.
> 7.  Under properties of the project select “Signing”
> •   Check “Sign the assembly”
> •   Type in the “Key File name:” in this case Utilities.SNK
> •   I de-selected “Protect my key file with a password” – too many to
> remember already.
> 8.  Build the Solution in Visual Studio
>
> 9.  Register the assembly. (from Admin command prompt)
>
> CD “C:\Windows\Microsoft.NET\Framework\v4.0.30319”
> regasm.exe 
> D:\VFP9\apps\c#\Utilities\Utilities\bin\Release\Utilities.dll
> /tlb /nologo /codebase
>
> Returned:
> Types registered successfully
> Assembly exported to 'D:\VFP9\apps\c#\Utilities\Utilities\bin\Release\
> Utilities.tlb’,
> and the type library was registered successfully
>
> C:\Windows\Microsoft.NET\Framework\v4.0.30319>
>
> 10. Then to use it in VFP ..
>
> oUtil = CREATEOBJECT("Utilities.FileInfo")
> nLines = oUtil.LineCount()
>
> -Original Message-
> From: ProfoxTech [mailto:profoxtech-boun...@leafe.com] On Behalf Of 
> Gianni Turri
> Sent: Saturday, 29 April 2017 2:24 AM
> To: profoxt...@leafe.com
> Subject: Re: Getting count of rows in a text file -- best approach?
>
> Test file of 1.67 GB correctly managed by FSO but not by VFP9 SP2 that 
> gives Error 43 (There is not enough memory to complete this operation).
>
> Test file of 5.31 GB correctly managed by FSO but not by VFP9 SP2 that 
> gives Error 1103 (Invalid seek offset).
>
> FSO method counts chr(10) / LF characters.
>
> alines() by default counts the occurrences of chr(10) plus the 
> occurrences of chr(13) minus the occurrences of chr(13) + chr(10)
>
> Please tell us more about the FLL and the code you used!
>
> Gianni
>
> On Sat, 29 Apr 2017 01:15:06 +1000, "Darren" <fox...@ozemail.com.au>
> 

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

2017-04-29 Thread Laurie Alvey
Hi All,

This is all very ingenious, but I am curious to know why you would want to
know the number of lines.

Laurie

On 29 April 2017 at 01:20, Darren <fox...@ozemail.com.au> wrote:

> Gianni
>
> The approach I took for .NET was ...  (And this is the first time I have
> done this so was a bit of a learning exercise) Again   very likely
> better ways to achieve this.
>
> Create a .NET DLL and use in VFP.
>
> Primary reference here:  http://www.tek-tips.com/faqs.cfm?fid=3836  (bit
> out of date)
>
> 1.  Using Visual Studio .NET create a C# Class Library project – named
> Utilities
> 2.  Add reference to “System.EnterpriseServices”
> 3.  Code the Class e.g.
> using System;
> using System.Text;
> using System.Linq;
> using System.Runtime.InteropServices;
> using System.Collections.Generic;
> using System.Threading.Tasks;
>
> namespace Utilities {
> public class FileInfo :  System.EnterpriseServices.ServicedComponent {
> public Int32 LineCount(String FilePath)
> {
> int count = System.IO.File.ReadLines(FilePath).Count() ;
> return count;
> }
> }
> }
>
> 4.  Create key pair (To sign the assembly).  In my case I used (from
> an Admin command window):
>
> CD “c:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin>”
> sn -k Utilities.SNK
>
> Returned:
>
> Microsoft (R) .NET Framework Strong Name Utility  Version 3.5.30729.1
> Copyright (c) Microsoft Corporation.  All rights reserved.
>
> Key pair written to Utilities.SNK
>
> 5.  Copy the SNK file to the DLL build directory.
>
> 6.  Edit Assembly.cs file.
>
> Change the entry [assembly: ComVisible(false)] to [assembly:
> ComVisible(true)]
>
> Ignore the [assembly: AssemblyKeyFile("")] step in Craig’s tip.  Instead
> add the SNK file in the “Signing” section per step 7.
> 7.  Under properties of the project select “Signing”
> •   Check “Sign the assembly”
> •   Type in the “Key File name:” in this case Utilities.SNK
> •   I de-selected “Protect my key file with a password” – too many to
> remember already.
> 8.  Build the Solution in Visual Studio
>
> 9.  Register the assembly. (from Admin command prompt)
>
> CD “C:\Windows\Microsoft.NET\Framework\v4.0.30319”
> regasm.exe D:\VFP9\apps\c#\Utilities\Utilities\bin\Release\Utilities.dll
> /tlb /nologo /codebase
>
> Returned:
> Types registered successfully
> Assembly exported to 'D:\VFP9\apps\c#\Utilities\Utilities\bin\Release\
> Utilities.tlb’,
> and the type library was registered successfully
>
> C:\Windows\Microsoft.NET\Framework\v4.0.30319>
>
> 10. Then to use it in VFP ..
>
> oUtil = CREATEOBJECT("Utilities.FileInfo")
> nLines = oUtil.LineCount()
>
> -Original Message-
> From: ProfoxTech [mailto:profoxtech-boun...@leafe.com] On Behalf Of
> Gianni Turri
> Sent: Saturday, 29 April 2017 2:24 AM
> To: profoxt...@leafe.com
> Subject: Re: Getting count of rows in a text file -- best approach?
>
> Test file of 1.67 GB correctly managed by FSO but not by VFP9 SP2 that
> gives Error 43 (There is not enough memory to complete this operation).
>
> Test file of 5.31 GB correctly managed by FSO but not by VFP9 SP2 that
> gives Error 1103 (Invalid seek offset).
>
> FSO method counts chr(10) / LF characters.
>
> alines() by default counts the occurrences of chr(10) plus the occurrences
> of chr(13) minus the occurrences of chr(13) + chr(10)
>
> Please tell us more about the FLL and the code you used!
>
> Gianni
>
> On Sat, 29 Apr 2017 01:15:06 +1000, "Darren" <fox...@ozemail.com.au>
> wrote:
>
> Many ways to do this.  I've compared 3.
>
> With a text file 350Mb | 5.3Million lines . Each method reported same # of
> lines.
>
> Timing done with high resolution timers so reasonably accurate. ...
>
> 1. C++ FLL  0.4064 seconds
> 2. C# .NET  1.2779 seconds :  Tip on how to do this is at
> http://www.tek-tips.com/faqs.cfm?fid=3836
> 3. FSO  7.3874 seconds :  (using OpenTextFile etc.)
>
> With a text file 2.6GB file. |  42 Million lines.  FSO died - reported no
> lines and finished in 0.0002 seconds - other two methods reported
> accurately.
>
> 1. C++ FLL  3.2426 seconds
> 2. C# .NET  10.0600 seconds
> 3. FSO  0.0002 seconds :  FAILED
>
> So I'd guess if you are doing many of these and time is an issue then
> perhaps a FLL approach might be beneficial.  Certainly if file is large
> enough (probably hits the 2Gb limit in VFP) then FSO is not an option.
>
> -Original Message-
> From: ProfoxTech [mailto:profoxtech-boun...@leafe.com] On Behalf

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

2017-04-28 Thread Darren
Gianni

The approach I took for .NET was ...  (And this is the first time I have done 
this so was a bit of a learning exercise) Again   very likely better ways 
to achieve this.

Create a .NET DLL and use in VFP.
 
Primary reference here:  http://www.tek-tips.com/faqs.cfm?fid=3836  (bit out of 
date)
 
1.  Using Visual Studio .NET create a C# Class Library project – named 
Utilities
2.  Add reference to “System.EnterpriseServices”  
3.  Code the Class e.g.
using System;
using System.Text;
using System.Linq;
using System.Runtime.InteropServices;
using System.Collections.Generic;
using System.Threading.Tasks;
 
namespace Utilities {
public class FileInfo :  System.EnterpriseServices.ServicedComponent {
public Int32 LineCount(String FilePath)
{
int count = System.IO.File.ReadLines(FilePath).Count() ;
return count;
}
}
}  
 
4.  Create key pair (To sign the assembly).  In my case I used (from an 
Admin command window): 
 
CD “c:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin>”
sn -k Utilities.SNK
 
Returned:
 
Microsoft (R) .NET Framework Strong Name Utility  Version 3.5.30729.1
Copyright (c) Microsoft Corporation.  All rights reserved.
 
Key pair written to Utilities.SNK
 
5.  Copy the SNK file to the DLL build directory.
 
6.  Edit Assembly.cs file. 
 
Change the entry [assembly: ComVisible(false)] to [assembly: ComVisible(true)]
 
Ignore the [assembly: AssemblyKeyFile("")] step in Craig’s tip.  Instead add 
the SNK file in the “Signing” section per step 7.   
7.  Under properties of the project select “Signing”
•   Check “Sign the assembly”
•   Type in the “Key File name:” in this case Utilities.SNK
•   I de-selected “Protect my key file with a password” – too many to 
remember already.
8.  Build the Solution in Visual Studio
 
9.  Register the assembly. (from Admin command prompt)
 
CD “C:\Windows\Microsoft.NET\Framework\v4.0.30319”
regasm.exe D:\VFP9\apps\c#\Utilities\Utilities\bin\Release\Utilities.dll /tlb 
/nologo /codebase
 
Returned:
Types registered successfully
Assembly exported to 
'D:\VFP9\apps\c#\Utilities\Utilities\bin\Release\Utilities.tlb’, 
and the type library was registered successfully
 
C:\Windows\Microsoft.NET\Framework\v4.0.30319>
 
10. Then to use it in VFP ..
 
oUtil = CREATEOBJECT("Utilities.FileInfo")
nLines = oUtil.LineCount()

-Original Message-
From: ProfoxTech [mailto:profoxtech-boun...@leafe.com] On Behalf Of Gianni Turri
Sent: Saturday, 29 April 2017 2:24 AM
To: profoxt...@leafe.com
Subject: Re: Getting count of rows in a text file -- best approach?

Test file of 1.67 GB correctly managed by FSO but not by VFP9 SP2 that gives 
Error 43 (There is not enough memory to complete this operation).

Test file of 5.31 GB correctly managed by FSO but not by VFP9 SP2 that gives 
Error 1103 (Invalid seek offset).

FSO method counts chr(10) / LF characters.

alines() by default counts the occurrences of chr(10) plus the occurrences of 
chr(13) minus the occurrences of chr(13) + chr(10)

Please tell us more about the FLL and the code you used!

Gianni

On Sat, 29 Apr 2017 01:15:06 +1000, "Darren" <fox...@ozemail.com.au> wrote:

Many ways to do this.  I've compared 3.

With a text file 350Mb | 5.3Million lines . Each method reported same # of 
lines.

Timing done with high resolution timers so reasonably accurate. ...

1. C++ FLL  0.4064 seconds  
2. C# .NET  1.2779 seconds :  Tip on how to do this is at 
http://www.tek-tips.com/faqs.cfm?fid=3836
3. FSO  7.3874 seconds :  (using OpenTextFile etc.)

With a text file 2.6GB file. |  42 Million lines.  FSO died - reported no lines 
and finished in 0.0002 seconds - other two methods reported accurately.

1. C++ FLL  3.2426 seconds  
2. C# .NET  10.0600 seconds
3. FSO  0.0002 seconds :  FAILED 

So I'd guess if you are doing many of these and time is an issue then perhaps a 
FLL approach might be beneficial.  Certainly if file is large enough (probably 
hits the 2Gb limit in VFP) then FSO is not an option.

-Original Message-
From: ProfoxTech [mailto:profoxtech-boun...@leafe.com] On Behalf Of Gianni Turri
Sent: Friday, 28 April 2017 11:39 PM
To: profoxt...@leafe.com
Subject: Re: Getting count of rows in a text file -- best approach?

Ok.

Anyway this is the slower method:

loFSO = createobject("Scripting.FileSystemObject")

loFile = loFSO.OpenTextFile(m.filename, 1)

do while ! loFile.AtEndOfStream()
loFile.SkipLine()
enddo

? loFile.Line -1

Gianni

On Fri, 28 Apr 2017 15:29:48 +0200, "Fernando D. Bozzo" <fdbo...@gmail.com> 
wrote:

>Forget my comment, I've tested it and works beautifully :)
>
>2017-04-28 15:24 GMT+02:00 Fernando D. Bozzo <fdbo...@gmail.com>:
>
>> Gianni, you skipped something very important, the part that skip the 
>> lines so the Line property is upda

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

2017-04-28 Thread Darren
Sure

 

The FLL ... code is below.  (And I am in no way fluent with C++ or FLL's so
may be much better ways ..)  

 

You 'll need a few other components but if you chase up how to create an FLL
then you'll have it sorted.

 

Once below is built into FLL it can be used directly in VFP.

Viz. SET library to ". fll"   |   lnLines =
FllGetFileLineCount()

 

 

void GetFileLineCount(ParamBlk *parm)

 

{

   

   #define p0 (parm->p[0].val) 

 

   ((char *)_HandToPtr(p0.ev_handle))[p0.ev_length] = '\0';

   

   char *srcFileName = (char *)_HandToPtr(p0.ev_handle) ; 

 

FILE *istream = fopen(srcFileName, "rb");

   

if (istream == 0)

   {

  _RetInt(-1, 10);

   }

   

int numLines = 0;

   

const int len = 8192;

 

char buf[8192];

   

do

 

{

 

if( feof(istream))

  {

 break;

  }

 

int nBytesRead = fread(buf, 1, len, istream);

 

if(nBytesRead <= 0)

  {

  break;

  }

 

  for(int i = 0; i < nBytesRead; i++)

  {

if(buf[i] == '\n')

  numLines++;

   }

   

} while(1);

 

fclose(istream);

 

   _RetInt(numLines, 10);



}

 

FoxInfo vfpUtilFLLInfo[] = 

{

   {"FllGetFileLineCount",  (FPFI) GetFileLineCount, 1, "C"}

};

 

 

#ifdef __cplusplus

extern "C"

#endif

   FoxTable _FoxTable = {

  (FoxTable *)0, sizeof(vfpUtilFLLInfo)/sizeof(FoxInfo),
vfpUtilFLLInfo

};

 

 

 

 

 

 

 

-Original Message-
From: ProfoxTech [mailto:profoxtech-boun...@leafe.com] On Behalf Of Gianni
Turri
Sent: Saturday, 29 April 2017 2:24 AM
To: profoxt...@leafe.com
Subject: Re: Getting count of rows in a text file -- best approach?

 

Test file of 1.67 GB correctly managed by FSO but not by VFP9 SP2 that gives
Error 43 (There is not enough memory to complete this operation).

 

Test file of 5.31 GB correctly managed by FSO but not by VFP9 SP2 that gives
Error 1103 (Invalid seek offset).

 

FSO method counts chr(10) / LF characters.

 

alines() by default counts the occurrences of chr(10) plus the occurrences
of chr(13) minus the occurrences of chr(13) + chr(10)

 

Please tell us more about the FLL and the code you used!

 

Gianni

 

On Sat, 29 Apr 2017 01:15:06 +1000, "Darren" <
<mailto:fox...@ozemail.com.au> fox...@ozemail.com.au> wrote:

 

Many ways to do this.  I've compared 3.

 

With a text file 350Mb | 5.3Million lines . Each method reported same # of
lines.

 

Timing done with high resolution timers so reasonably accurate. ...

 

1. C++ FLL0.4064 seconds  

2. C# .NET1.2779 seconds :  Tip on how to do this is at
<http://www.tek-tips.com/faqs.cfm?fid=3836>
http://www.tek-tips.com/faqs.cfm?fid=3836

3. FSO  7.3874 seconds :  (using OpenTextFile etc.)

 

With a text file 2.6GB file. |  42 Million lines.  FSO died - reported no
lines and finished in 0.0002 seconds - other two methods reported
accurately.

 

1. C++ FLL3.2426 seconds  

2. C# .NET10.0600 seconds

3. FSO  0.0002 seconds :  FAILED 

 

So I'd guess if you are doing many of these and time is an issue then
perhaps a FLL approach might be beneficial.  Certainly if file is large
enough (probably hits the 2Gb limit in VFP) then FSO is not an option.

 

-Original Message-

From: ProfoxTech [ <mailto:profoxtech-boun...@leafe.com>
mailto:profoxtech-boun...@leafe.com] On Behalf Of Gianni Turri

Sent: Friday, 28 April 2017 11:39 PM

To:  <mailto:profoxt...@leafe.com> profoxt...@leafe.com

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

 

Ok.

 

Anyway this is the slower method:

 

loFSO = createobject("Scripting.FileSystemObject")

 

loFile = loFSO.OpenTextFile(m.filename, 1)

 

do while ! loFile.AtEndOfStream()

loFile.SkipLine()

enddo

 

? loFile.Line -1

 

Gianni

 

On Fri, 28 Apr 2017 15:29:48 +0200, "Fernando D. Bozzo" <
<mailto:fdbo...@gmail.com> fdbo...@gmail.com> wrote:

 

>Forget my comment, I've tested it and works beautifully :)

> 

>2017-04-28 15:24 GMT+02:00 Fernando D. Bozzo < <mailto:fdbo...@gmail.com>
fdbo...@gmail.com>:

> 

>> Gianni, you skipped something very important, the part that skip the 

>> lines so the Line property is updated:

>> 

>> 'Skip lines one by one Do While txsInput.AtEndOfStream <> True

>> txsInput.SkipLine ' or strTemp = txsInput.ReadLineLoop

>> 

>> 2017-04-28 15:08 GMT+02:00 Gianni Turri < <mailto:gianni...@gmail.com>
gianni...@gmail.com>:

>> 

>>> On Thu, 27 Apr 2017 17:12:49 +0200, "Fernando D. Bozzo" < 

>>>

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

2017-04-28 Thread Malcolm Greene
Gianni,

When working with large files like you are you may want to consider
using Python. This need pushed me to explore Python and I've never
looked back. Working with text files is a great way to dip your toes
into Python without feeling you need to learn the full language.

Python has no practical limits on file size other than those imposed by
the OS and the time required to process huge files.

Good luck!

Malcolm

___
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/1493422092.1800649.959916784.1c3a8...@webmail.messagingengine.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.


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

2017-04-28 Thread Gianni Turri
Test file of 1.67 GB correctly managed by FSO but not by VFP9 SP2 that gives 
Error 43 (There is not enough memory to complete this operation).

Test file of 5.31 GB correctly managed by FSO but not by VFP9 SP2 that gives 
Error 1103 (Invalid seek offset).

FSO method counts chr(10) / LF characters.

alines() by default counts the occurrences of chr(10) plus the occurrences of 
chr(13) minus the occurrences of chr(13) + chr(10)

Please tell us more about the FLL and the code you used!

Gianni

On Sat, 29 Apr 2017 01:15:06 +1000, "Darren" <fox...@ozemail.com.au> wrote:

Many ways to do this.  I've compared 3.

With a text file 350Mb | 5.3Million lines . Each method reported same # of 
lines.

Timing done with high resolution timers so reasonably accurate. ...

1. C++ FLL  0.4064 seconds  
2. C# .NET  1.2779 seconds :  Tip on how to do this is at 
http://www.tek-tips.com/faqs.cfm?fid=3836
3. FSO  7.3874 seconds :  (using OpenTextFile etc.)

With a text file 2.6GB file. |  42 Million lines.  FSO died - reported no
lines and finished in 0.0002 seconds - other two methods reported
accurately.

1. C++ FLL  3.2426 seconds  
2. C# .NET  10.0600 seconds
3. FSO  0.0002 seconds :  FAILED 

So I'd guess if you are doing many of these and time is an issue then
perhaps a FLL approach might be beneficial.  Certainly if file is large
enough (probably hits the 2Gb limit in VFP) then FSO is not an option.

-Original Message-
From: ProfoxTech [mailto:profoxtech-boun...@leafe.com] On Behalf Of Gianni Turri
Sent: Friday, 28 April 2017 11:39 PM
To: profoxt...@leafe.com
Subject: Re: Getting count of rows in a text file -- best approach?

Ok.

Anyway this is the slower method:

loFSO = createobject("Scripting.FileSystemObject")

loFile = loFSO.OpenTextFile(m.filename, 1)

do while ! loFile.AtEndOfStream()
loFile.SkipLine()
enddo

? loFile.Line -1

Gianni

On Fri, 28 Apr 2017 15:29:48 +0200, "Fernando D. Bozzo" <fdbo...@gmail.com> 
wrote:

>Forget my comment, I've tested it and works beautifully :)
>
>2017-04-28 15:24 GMT+02:00 Fernando D. Bozzo <fdbo...@gmail.com>:
>
>> Gianni, you skipped something very important, the part that skip the 
>> lines so the Line property is updated:
>>
>> 'Skip lines one by one Do While txsInput.AtEndOfStream <> True
>> txsInput.SkipLine ' or strTemp = txsInput.ReadLineLoop
>>
>> 2017-04-28 15:08 GMT+02:00 Gianni Turri <gianni...@gmail.com>:
>>
>>> On Thu, 27 Apr 2017 17:12:49 +0200, "Fernando D. Bozzo" < 
>>> fdbo...@gmail.com> wrote:
>>>
>>> >Hi Mike:
>>> >
>>> >A very fast method is using the FileSystemObject:
>>> >
>>> >loFSO = CREATEOBJECT("Scripting.FileSystemObject")
>>> >loFile1 = loFSO.OpenTextFile(lcArchivo1, 1)
>>> >
>>> >Look at the syntax on Microsoft web site for the read method.
>>> >It does not have the limitation of VFP's fread/fgets
>>>
>>> loFSO = createobject("Scripting.FileSystemObject")
>>>
>>> loFile = loFSO.OpenTextFile(m.filename, 8, .f.) ? loFile.Line -1
>>>
>>> This method overcome VFP memory / file size limits.
>>>
>>> Source:
>>> http://stackoverflow.com/questions/7416553/function-to-count-number-of-lines-in-a-text-file

___
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/p0q6gc9cisfda2hrsaf5vsi0jmqnap1...@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.


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

2017-04-28 Thread Darren
Update to below.

Using FSO doesn't crash - I missed the parameters  ...  8,.F.)  but it is
somewhat slower.  

59.3775 seconds using the OpenTextFile(, 8, .F.)  approach and
164.4686 seconds using the AtEndOfStream() | SkipLine approach. 

-Original Message-
From: ProfoxTech [mailto:profoxtech-boun...@leafe.com] On Behalf Of Darren
Sent: Saturday, 29 April 2017 1:15 AM
To: profoxt...@leafe.com
Subject: RE: Getting count of rows in a text file -- best approach?

Many ways to do this.  I've compared 3.

With a text file 350Mb | 5.3Million lines . Each method reported same # of
lines.

Timing done with high resolution timers so reasonably accurate. ...

1. C++ FLL  0.4064 seconds  
2. C# .NET  1.2779 seconds :  Tip on how to do this is at
http://www.tek-tips.com/faqs.cfm?fid=3836
3. FSO  7.3874 seconds :  (using OpenTextFile etc.)

With a text file 2.6GB file. |  42 Million lines.  FSO died - reported no
lines and finished in 0.0002 seconds - other two methods reported
accurately.

1. C++ FLL  3.2426 seconds  
2. C# .NET  10.0600 seconds
3. FSO  0.0002 seconds :  FAILED 

So I'd guess if you are doing many of these and time is an issue then
perhaps a FLL approach might be beneficial.  Certainly if file is large
enough (probably hits the 2Gb limit in VFP) then FSO is not an option.

-Original Message-
From: ProfoxTech [mailto:profoxtech-boun...@leafe.com] On Behalf Of Gianni
Turri
Sent: Friday, 28 April 2017 11:39 PM
To: profoxt...@leafe.com
Subject: Re: Getting count of rows in a text file -- best approach?

Ok.

Anyway this is the slower method:

loFSO = createobject("Scripting.FileSystemObject")

loFile = loFSO.OpenTextFile(m.filename, 1)

do while ! loFile.AtEndOfStream()
loFile.SkipLine()
enddo

? loFile.Line -1

Gianni

On Fri, 28 Apr 2017 15:29:48 +0200, "Fernando D. Bozzo" <fdbo...@gmail.com>
wrote:

>Forget my comment, I've tested it and works beautifully :)
>
>2017-04-28 15:24 GMT+02:00 Fernando D. Bozzo <fdbo...@gmail.com>:
>
>> Gianni, you skipped something very important, the part that skip the 
>> lines so the Line property is updated:
>>
>> 'Skip lines one by one Do While txsInput.AtEndOfStream <> True
>> txsInput.SkipLine ' or strTemp = txsInput.ReadLineLoop
>>
>> 2017-04-28 15:08 GMT+02:00 Gianni Turri <gianni...@gmail.com>:
>>
>>> On Thu, 27 Apr 2017 17:12:49 +0200, "Fernando D. Bozzo" < 
>>> fdbo...@gmail.com> wrote:
>>>
>>> >Hi Mike:
>>> >
>>> >A very fast method is using the FileSystemObject:
>>> >
>>> >loFSO = CREATEOBJECT("Scripting.FileSystemObject")
>>> >loFile1 = loFSO.OpenTextFile(lcArchivo1, 1)
>>> >
>>> >Look at the syntax on Microsoft web site for the read method.
>>> >It does not have the limitation of VFP's fread/fgets
>>>
>>> loFSO = createobject("Scripting.FileSystemObject")
>>>
>>> loFile = loFSO.OpenTextFile(m.filename, 8, .f.) ? loFile.Line -1
>>>
>>> This method overcome VFP memory / file size limits.
>>>
>>> Source:
>>> http://stackoverflow.com/questions/7416553/function-to-count-number-
>>> of-lines-in-a-text-file

[excessive quoting removed by server]

___
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/002a01d2c038$01e76850$05b638f0$@ozemail.com.au
** 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.


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

2017-04-28 Thread Darren
Many ways to do this.  I've compared 3.

With a text file 350Mb | 5.3Million lines . Each method reported same # of
lines.

Timing done with high resolution timers so reasonably accurate. ...

1. C++ FLL  0.4064 seconds  
2. C# .NET  1.2779 seconds :  Tip on how to do this is at
http://www.tek-tips.com/faqs.cfm?fid=3836
3. FSO  7.3874 seconds :  (using OpenTextFile etc.)

With a text file 2.6GB file. |  42 Million lines.  FSO died - reported no
lines and finished in 0.0002 seconds - other two methods reported
accurately.

1. C++ FLL  3.2426 seconds  
2. C# .NET  10.0600 seconds
3. FSO  0.0002 seconds :  FAILED 

So I'd guess if you are doing many of these and time is an issue then
perhaps a FLL approach might be beneficial.  Certainly if file is large
enough (probably hits the 2Gb limit in VFP) then FSO is not an option.

-Original Message-
From: ProfoxTech [mailto:profoxtech-boun...@leafe.com] On Behalf Of Gianni
Turri
Sent: Friday, 28 April 2017 11:39 PM
To: profoxt...@leafe.com
Subject: Re: Getting count of rows in a text file -- best approach?

Ok.

Anyway this is the slower method:

loFSO = createobject("Scripting.FileSystemObject")

loFile = loFSO.OpenTextFile(m.filename, 1)

do while ! loFile.AtEndOfStream()
loFile.SkipLine()
enddo

? loFile.Line -1

Gianni

On Fri, 28 Apr 2017 15:29:48 +0200, "Fernando D. Bozzo" <fdbo...@gmail.com>
wrote:

>Forget my comment, I've tested it and works beautifully :)
>
>2017-04-28 15:24 GMT+02:00 Fernando D. Bozzo <fdbo...@gmail.com>:
>
>> Gianni, you skipped something very important, the part that skip the 
>> lines so the Line property is updated:
>>
>> 'Skip lines one by one Do While txsInput.AtEndOfStream <> True
>> txsInput.SkipLine ' or strTemp = txsInput.ReadLineLoop
>>
>> 2017-04-28 15:08 GMT+02:00 Gianni Turri <gianni...@gmail.com>:
>>
>>> On Thu, 27 Apr 2017 17:12:49 +0200, "Fernando D. Bozzo" < 
>>> fdbo...@gmail.com> wrote:
>>>
>>> >Hi Mike:
>>> >
>>> >A very fast method is using the FileSystemObject:
>>> >
>>> >loFSO = CREATEOBJECT("Scripting.FileSystemObject")
>>> >loFile1 = loFSO.OpenTextFile(lcArchivo1, 1)
>>> >
>>> >Look at the syntax on Microsoft web site for the read method.
>>> >It does not have the limitation of VFP's fread/fgets
>>>
>>> loFSO = createobject("Scripting.FileSystemObject")
>>>
>>> loFile = loFSO.OpenTextFile(m.filename, 8, .f.) ? loFile.Line -1
>>>
>>> This method overcome VFP memory / file size limits.
>>>
>>> Source:
>>> http://stackoverflow.com/questions/7416553/function-to-count-number-
>>> of-lines-in-a-text-file

[excessive quoting removed by server]

___
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/002501d2c032$3900feb0$ab02fc10$@ozemail.com.au
** 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.


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

2017-04-28 Thread Gianni Turri
Ok.

Anyway this is the slower method:

loFSO = createobject("Scripting.FileSystemObject")

loFile = loFSO.OpenTextFile(m.filename, 1)

do while ! loFile.AtEndOfStream()
loFile.SkipLine()
enddo

? loFile.Line -1

Gianni

On Fri, 28 Apr 2017 15:29:48 +0200, "Fernando D. Bozzo"  
wrote:

>Forget my comment, I've tested it and works beautifully :)
>
>2017-04-28 15:24 GMT+02:00 Fernando D. Bozzo :
>
>> Gianni, you skipped something very important, the part that skip the lines
>> so the Line property is updated:
>>
>> 'Skip lines one by one Do While txsInput.AtEndOfStream <> True
>> txsInput.SkipLine ' or strTemp = txsInput.ReadLineLoop
>>
>> 2017-04-28 15:08 GMT+02:00 Gianni Turri :
>>
>>> On Thu, 27 Apr 2017 17:12:49 +0200, "Fernando D. Bozzo" <
>>> fdbo...@gmail.com> wrote:
>>>
>>> >Hi Mike:
>>> >
>>> >A very fast method is using the FileSystemObject:
>>> >
>>> >loFSO = CREATEOBJECT("Scripting.FileSystemObject")
>>> >loFile1 = loFSO.OpenTextFile(lcArchivo1, 1)
>>> >
>>> >Look at the syntax on Microsoft web site for the read method.
>>> >It does not have the limitation of VFP's fread/fgets
>>>
>>> loFSO = createobject("Scripting.FileSystemObject")
>>>
>>> loFile = loFSO.OpenTextFile(m.filename, 8, .f.)
>>> ? loFile.Line -1
>>>
>>> This method overcome VFP memory / file size limits.
>>>
>>> Source:
>>> http://stackoverflow.com/questions/7416553/function-to-count-number-of-lines-in-a-text-file

___
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/2dh6gcluh3cvtrvj8avto4dgnm489ia...@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.


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

2017-04-28 Thread Gianni Turri
No, in the call to OpenTextFile 8 means "append" and .f. means don't create if 
the file don't exist.

loFile = loFSO.OpenTextFile(m.filename, 8, .f.)

So:

? loFile.Line -1

gives the correct result.

Try it!

Gianni

On Fri, 28 Apr 2017 15:24:17 +0200, "Fernando D. Bozzo"  
wrote:

>Gianni, you skipped something very important, the part that skip the lines
>so the Line property is updated:
>
>'Skip lines one by one Do While txsInput.AtEndOfStream <> True
>txsInput.SkipLine ' or strTemp = txsInput.ReadLineLoop
>
>2017-04-28 15:08 GMT+02:00 Gianni Turri :
>
>> loFSO = createobject("Scripting.FileSystemObject")
>>
>> loFile = loFSO.OpenTextFile(m.filename, 8, .f.)
>> ? loFile.Line -1
>>
>> This method overcome VFP memory / file size limits.
>>
>> Source:
>> http://stackoverflow.com/questions/7416553/function-to-count-number-of-lines-in-a-text-file

___
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/mug6gcp0v0k36bohsf2ofc3jhu58ger...@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.


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

2017-04-28 Thread Fernando D. Bozzo
Forget my comment, I've tested it and works beautifully :)





2017-04-28 15:24 GMT+02:00 Fernando D. Bozzo :

> Gianni, you skipped something very important, the part that skip the lines
> so the Line property is updated:
>
> 'Skip lines one by one Do While txsInput.AtEndOfStream <> True
> txsInput.SkipLine ' or strTemp = txsInput.ReadLineLoop
>
>
>
> 2017-04-28 15:08 GMT+02:00 Gianni Turri :
>
>> On Thu, 27 Apr 2017 17:12:49 +0200, "Fernando D. Bozzo" <
>> fdbo...@gmail.com> wrote:
>>
>> >Hi Mike:
>> >
>> >A very fast method is using the FileSystemObject:
>> >
>> >loFSO = CREATEOBJECT("Scripting.FileSystemObject")
>> >loFile1 = loFSO.OpenTextFile(lcArchivo1, 1)
>> >
>> >Look at the syntax on Microsoft web site for the read method.
>> >It does not have the limitation of VFP's fread/fgets
>>
>> loFSO = createobject("Scripting.FileSystemObject")
>>
>> loFile = loFSO.OpenTextFile(m.filename, 8, .f.)
>> ? loFile.Line -1
>>
>> This method overcome VFP memory / file size limits.
>>
>> Source:
>> http://stackoverflow.com/questions/7416553/function-to-count
>> -number-of-lines-in-a-text-file
>>
>> --
>> Gianni
>>
[excessive quoting removed by server]

___
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/CAGQ_Jumn7d5vAYK69Firt3Mkgw86my08E2dYYW-yteCw_XH=u...@mail.gmail.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.


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

2017-04-28 Thread Fernando D. Bozzo
Gianni, you skipped something very important, the part that skip the lines
so the Line property is updated:

'Skip lines one by one Do While txsInput.AtEndOfStream <> True
txsInput.SkipLine ' or strTemp = txsInput.ReadLineLoop



2017-04-28 15:08 GMT+02:00 Gianni Turri :

> On Thu, 27 Apr 2017 17:12:49 +0200, "Fernando D. Bozzo" 
> wrote:
>
> >Hi Mike:
> >
> >A very fast method is using the FileSystemObject:
> >
> >loFSO = CREATEOBJECT("Scripting.FileSystemObject")
> >loFile1 = loFSO.OpenTextFile(lcArchivo1, 1)
> >
> >Look at the syntax on Microsoft web site for the read method.
> >It does not have the limitation of VFP's fread/fgets
>
> loFSO = createobject("Scripting.FileSystemObject")
>
> loFile = loFSO.OpenTextFile(m.filename, 8, .f.)
> ? loFile.Line -1
>
> This method overcome VFP memory / file size limits.
>
> Source:
> http://stackoverflow.com/questions/7416553/function-to-
> count-number-of-lines-in-a-text-file
>
> --
> Gianni
>
[excessive quoting removed by server]

___
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/cagq_jum2sv-y3owtuh8otvctzuzheqef-2oce0mtxil4ywd...@mail.gmail.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.


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

2017-04-28 Thread Gianni Turri
On Thu, 27 Apr 2017 17:12:49 +0200, "Fernando D. Bozzo"  
wrote:

>Hi Mike:
>
>A very fast method is using the FileSystemObject:
>
>loFSO = CREATEOBJECT("Scripting.FileSystemObject")
>loFile1 = loFSO.OpenTextFile(lcArchivo1, 1)
>
>Look at the syntax on Microsoft web site for the read method.
>It does not have the limitation of VFP's fread/fgets

loFSO = createobject("Scripting.FileSystemObject")

loFile = loFSO.OpenTextFile(m.filename, 8, .f.)
? loFile.Line -1

This method overcome VFP memory / file size limits.

Source:
http://stackoverflow.com/questions/7416553/function-to-count-number-of-lines-in-a-text-file

-- 
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/agf6gcldo797r44fpeknmbsdjefc83d...@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.


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

2017-04-28 Thread Ted Roche
"One of the great things about FoxPro," a wise man (or was it a wise
guy?) said, a couple of decades ago, "is that there's three ways to do
anything in FoxPro. Or no way at all."

This thread is a great illustration of this. Every three days, someone
else drifts through the forum and suggests MEMLINES(), MLINE(),
ALINES(), LLFFs, FileToStr(), the OS's FileSystemObject, APPEND,
APPEND TO MEMO, file size limits (16Mb or 2Gb, depending on which),
shelling out to PowerShell (1), using the Linux wc (wordcount) ported
to Windows or using the new Linux under Windows, using Office
Automation to import the file to Excel (or Word!) and querying the
number of lines, or some other solution.

There's some elegant solutions in Perl or Python, too, if you happen
to have them installed.

(1) 
https://blogs.technet.microsoft.com/heyscriptingguy/2011/10/09/use-a-powershell-cmdlet-to-count-files-words-and-lines/


On Fri, Apr 28, 2017 at 6:22 AM, Laurie Alvey  wrote:
> Have you thought about the ALINES() function?
>
> Laurie
>
> On 27 April 2017 at 16:12, Fernando D. Bozzo  wrote:
>
>> Hi Mike:
>>
>> A very fast method is using the FileSystemObject:
>>
>> loFSO = CREATEOBJECT("Scripting.FileSystemObject")
>> loFile1 = loFSO.OpenTextFile(lcArchivo1, 1)
>>
>> Look at the syntax on Microsoft web site for the read method.
>> It does not have the limitation of VFP's fread/fgets
>>
>> Regards
>>
>> El 21/4/2017 4:45 p. m., 
>> escribió:
>>
>> > 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.
>> >
>> > tia,
>> > --Mike
>> >
>> >
[excessive quoting removed by server]

___
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/CACW6n4s9k5YnOnZJk0o0r_rpSSGi+dLdRBBKUa88g8xZz6=o...@mail.gmail.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.

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

2017-04-28 Thread Fernando D. Bozzo
Yeah, and did you try reading a +1GiB txt file? ;-)



El 28/4/2017 12:22, "Laurie Alvey"  escribió:

> Have you thought about the ALINES() function?
>
> Laurie
>
> On 27 April 2017 at 16:12, Fernando D. Bozzo  wrote:
>
> > Hi Mike:
> >
> > A very fast method is using the FileSystemObject:
> >
> > loFSO = CREATEOBJECT("Scripting.FileSystemObject")
> > loFile1 = loFSO.OpenTextFile(lcArchivo1, 1)
> >
> > Look at the syntax on Microsoft web site for the read method.
> > It does not have the limitation of VFP's fread/fgets
> >
> > Regards
> >
> > El 21/4/2017 4:45 p. m., 
> > escribió:
> >
> > > 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.
> > >
> > > tia,
> > > --Mike
> > >
> > >
[excessive quoting removed by server]

___
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/cagq_jukezybcdz3etb1qvnsp5yjs0uz0s7pqgnpwtymogvh...@mail.gmail.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.

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

2017-04-28 Thread Laurie Alvey
Have you thought about the ALINES() function?

Laurie

On 27 April 2017 at 16:12, Fernando D. Bozzo  wrote:

> Hi Mike:
>
> A very fast method is using the FileSystemObject:
>
> loFSO = CREATEOBJECT("Scripting.FileSystemObject")
> loFile1 = loFSO.OpenTextFile(lcArchivo1, 1)
>
> Look at the syntax on Microsoft web site for the read method.
> It does not have the limitation of VFP's fread/fgets
>
> Regards
>
> El 21/4/2017 4:45 p. m., 
> escribió:
>
> > 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.
> >
> > tia,
> > --Mike
> >
> >
[excessive quoting removed by server]

___
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/camvtr9esszqnquyutqg7mlarpxhpv+04_cw-4+n90wegzfu...@mail.gmail.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.

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

2017-04-27 Thread Fernando D. Bozzo
Hi Mike:

A very fast method is using the FileSystemObject:

loFSO = CREATEOBJECT("Scripting.FileSystemObject")
loFile1 = loFSO.OpenTextFile(lcArchivo1, 1)

Look at the syntax on Microsoft web site for the read method.
It does not have the limitation of VFP's fread/fgets

Regards

El 21/4/2017 4:45 p. m., 
escribió:

> 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.
>
> tia,
> --Mike
>
>
[excessive quoting removed by server]

___
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/cagq_jumz+u+fpxu5dh64c0sbyffts+t4y8gyk+0ax74qtmp...@mail.gmail.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.

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

2017-04-27 Thread Gianni Turri
On Thu, 27 Apr 2017 19:02:39 +0800, Man-wai Chang  wrote:

>Sorry, memlines() not mline()

The returned count can be wrong due to the 8192 characters max line lenght 
limit.

Only the method that counts the carriage return characters give the correct 
result.

-- 
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/68n3gcpk1v12loom0gjm7nev4agls07...@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.


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

2017-04-27 Thread Man-wai Chang
Sorry, memlines() not mline()

On Fri, Apr 21, 2017 at 10:44 PM,
 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.
>
> tia,
> --Mike
>
>
[excessive quoting removed by server]

___
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/CAGv=mjdaj04sof_peofeujzf_zwpsrtemt1akuec+j9yiqy...@mail.gmail.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.


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

2017-04-27 Thread Man-wai Chang
How about an old functions like MLINE()?

On Fri, Apr 21, 2017 at 10:44 PM,
 wrote:
> VF9SP2
>
> Currently, I'm simply doing this for now:
>
> RowCount = OCCURS(CHR(13),FILETOSTR(m.Filename))

-- 
 .~. Might, Courage, Vision. SINCERITY!
/ v \ 64-bit Fedora 25 Server Spin
/( _ )\ http://sites.google.com/site/changmw
^ ^ May the Force and farces be with you!

___
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/CAGv=mjbr-fb-jjd5lvq9+rchdiibtfqzenmzu_ctxsb-af3...@mail.gmail.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.


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

2017-04-26 Thread Brant E. Layton
|My experience was moving PDF files in and out of SQLServer tables - found an 
abrupt truncation at the 16,777,184 mark...


Brant Layton|
|480.964.1316|
On 4/26/2017 12:57 PM, profoxtech-requ...@leafe.com wrote:

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




--- StripMime Report -- processed MIME parts ---
multipart/alternative
 text/plain (text body -- kept)
 text/html
---

___
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/cb75d8db-8dda-c4cf-8d04-66b77a17f...@futureone.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.


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

2017-04-26 Thread Fred Taylor
Sure looks like you can load larger than 16MB.  Though the help file does
say a 16MB limit on memory variables.

Fred

On Wed, Apr 26, 2017 at 11:44 AM, <
mbsoftwaresoluti...@mbsoftwaresolutions.com> wrote:

> On 2017-04-26 12:31, Brant E. Layton wrote:
>
>> Just a reminder - STRTOFILE and FILETOSTR are limited by the size of a
>> memory variable - 16,384K bytes (16,777.184 bytes).
>>
>> Had to fix some software that was truncating PDF files at 16 MB...
>> ||
>>
>
>
> Looked up the Visual Foxpro System Capabilities:
> Maximum # of characters per character string or memory variable.  =
> 16,777,184
>
>
> That seems odd.  I thought I had tested with a file larger than 16 MB and
> gotten correct numbers?
>
>
[excessive quoting removed by server]

___
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/cajcbksrwspdzwdz3figr2v9crscbekurg+jxjqyd7ygxeup...@mail.gmail.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.


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

2017-04-26 Thread mbsoftwaresolutions

On 2017-04-26 12:31, Brant E. Layton wrote:

Just a reminder - STRTOFILE and FILETOSTR are limited by the size of a
memory variable - 16,384K bytes (16,777.184 bytes).

Had to fix some software that was truncating PDF files at 16 MB...
||



Looked up the Visual Foxpro System Capabilities:
Maximum # of characters per character string or memory variable.  = 
16,777,184



That seems odd.  I thought I had tested with a file larger than 16 MB 
and gotten correct numbers?



___
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/5f473e1d8f5d2390761dfe07a486c...@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.


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

2017-04-26 Thread Brant E. Layton
Just a reminder - STRTOFILE and FILETOSTR are limited by the size of a memory 
variable - 16,384K bytes (16,777.184 bytes).


Had to fix some software that was truncating PDF files at 16 MB...
||

|Brant Layton|
|480.964.1316|
On 4/25/2017 6:00 PM, profoxtech-requ...@leafe.com wrote:

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




--- StripMime Report -- processed MIME parts ---
multipart/alternative
 text/plain (text body -- kept)
 text/html
---

___
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/4b337c54-d2b2-a698-828a-b15bfad70...@futureone.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.


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

2017-04-21 Thread Richard Kaye
You just listen to Ted, Mike. He is invariably right. <g,d>

It's all in memory either way. As you saw the overhead either way isn't much 
different.

--

rk
-Original Message-
From: ProfoxTech [mailto:profoxtech-boun...@leafe.com] On Behalf Of 
mbsoftwaresoluti...@mbsoftwaresolutions.com
Sent: Friday, April 21, 2017 4:50 PM
To: profoxt...@leafe.com
Subject: Re: Getting count of rows in a text file -- best approach?

On 2017-04-21 16:47, Ted Roche wrote:
> On Fri, Apr 21, 2017 at 4:37 PM,
> <mbsoftwaresoluti...@mbsoftwaresolutions.com> wrote:
> 
>> Testing showed these two pretty much a dead heat:
>> 
>>   RowCount = OCCURS(CHR(13),FILETOSTR(m.Filename))
>>   RowCount = ALINES(aCrap,FILETOSTR(m.Filename))
>> 
> 
> But on the bright side, with Richard's one-liner, you're done reading
> in the file: it's sitting in the array.

I don't see the difference; yes, it's in the array, but what do I want 
it for after that?  For my processing, I was just comparing this year's 
file to last year's file and seeing how their record counts differed.  
Not really working with the file after that.

Actually, in looking at those two tests above, I would think the OCCURS 
would be better because in the upper, the file bulk is in whatever 
temporary variable created by FILETOSTR(..) but then in Richard's ALINES 
test, that same file is in the temporary variable like Test1 BUT it's 
ALSO in the aCrap array.  Correct


[excessive quoting removed by server]

___
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/bn4pr10mb0913c4d508bb4060af0a5f17d2...@bn4pr10mb0913.namprd10.prod.outlook.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.


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

2017-04-21 Thread mbsoftwaresolutions

On 2017-04-21 16:47, Ted Roche wrote:

On Fri, Apr 21, 2017 at 4:37 PM,
 wrote:


Testing showed these two pretty much a dead heat:

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



But on the bright side, with Richard's one-liner, you're done reading
in the file: it's sitting in the array.


I don't see the difference; yes, it's in the array, but what do I want 
it for after that?  For my processing, I was just comparing this year's 
file to last year's file and seeing how their record counts differed.  
Not really working with the file after that.


Actually, in looking at those two tests above, I would think the OCCURS 
would be better because in the upper, the file bulk is in whatever 
temporary variable created by FILETOSTR(..) but then in Richard's ALINES 
test, that same file is in the temporary variable like Test1 BUT it's 
ALSO in the aCrap array.  Correct



___
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/ec289a88d139dd7c29303d359d7c5...@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.


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

2017-04-21 Thread Ted Roche
On Fri, Apr 21, 2017 at 4:37 PM,
 wrote:

> Testing showed these two pretty much a dead heat:
>
>   RowCount = OCCURS(CHR(13),FILETOSTR(m.Filename))
>   RowCount = ALINES(aCrap,FILETOSTR(m.Filename))
>

But on the bright side, with Richard's one-liner, you're done reading
in the file: it's sitting in the array.

-- 
Ted Roche
Ted Roche & Associates, LLC
http://www.tedroche.com

___
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/cacw6n4uahyfo_kepedovetxprmhv1pkriqskhvzrmq3gzk9...@mail.gmail.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.


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

2017-04-21 Thread Richard Kaye
Thanks. I was curious. :-)

--

rk
-Original Message-
From: ProfoxTech [mailto:profoxtech-boun...@leafe.com] On Behalf Of 
mbsoftwaresoluti...@mbsoftwaresolutions.com
Sent: Friday, April 21, 2017 4:38 PM
To: profoxt...@leafe.com
Subject: RE: Getting count of rows in a text file -- best approach?

On 2017-04-21 11:24, Richard Kaye wrote:
> Only when it fits the situation. :-)
> 
> Dirty? Really? One line of code returns the number of rows in your
> string. Which was your original question.

My solution was 1 line too:  RowCount = 
OCCURS(CHR(13),FILETOSTR(m.Filename))  


> 
> Benchmark it and you'll find out which one is faster and whether or
> not you can live with that slightly soiled sensations... ;-)


Testing showed these two pretty much a dead heat:

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


___
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/bn4pr10mb0913b5643363471841eb34acd2...@bn4pr10mb0913.namprd10.prod.outlook.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.


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

2017-04-21 Thread mbsoftwaresolutions

On 2017-04-21 11:24, Richard Kaye wrote:

Only when it fits the situation. :-)

Dirty? Really? One line of code returns the number of rows in your
string. Which was your original question.


My solution was 1 line too:  RowCount = 
OCCURS(CHR(13),FILETOSTR(m.Filename))  





Benchmark it and you'll find out which one is faster and whether or
not you can live with that slightly soiled sensations... ;-)



Testing showed these two pretty much a dead heat:

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



___
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/600a4ec877828599934fffecd9660...@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.


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

2017-04-21 Thread Richard Kaye
Did you benchmark with ALINES? :-)

--

rk
-Original Message-
From: ProfoxTech [mailto:profoxtech-boun...@leafe.com] On Behalf Of 
mbsoftwaresoluti...@mbsoftwaresolutions.com
Sent: Friday, April 21, 2017 2:34 PM
To: profoxt...@leafe.com
Subject: Re: Getting count of rows in a text file -- best approach?

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/bn4pr10mb0913559a8d4cd6f87e4e8c30d2...@bn4pr10mb0913.namprd10.prod.outlook.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.


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

2017-04-21 Thread mbsoftwaresolutions

On 2017-04-21 11:27, Gianni Turri wrote:
On Fri, 21 Apr 2017 17:02:23 +0200, Gianni Turri  
wrote:


On Fri, 21 Apr 2017 10:44:34 -0400, 
mbsoftwaresoluti...@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/b8d916da69790690cb0db19e4033d...@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.


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

2017-04-21 Thread Gianni Turri
On Fri, 21 Apr 2017 17:02:23 +0200, Gianni Turri  wrote:

>On Fri, 21 Apr 2017 10:44:34 -0400, 
>mbsoftwaresoluti...@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.

-- 
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/m69kfcd71gcd81jhctf2nbe3aj1fa57...@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.


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

2017-04-21 Thread Richard Kaye
Only when it fits the situation. :-)

Dirty? Really? One line of code returns the number of rows in your string. 
Which was your original question.

Benchmark it and you'll find out which one is faster and whether or not you can 
live with that slightly soiled sensations... ;-)

--

rk
-Original Message-
From: ProfoxTech [mailto:profoxtech-boun...@leafe.com] On Behalf Of 
mbsoftwaresoluti...@mbsoftwaresolutions.com
Sent: Friday, April 21, 2017 11:20 AM
To: profoxt...@leafe.com
Subject: RE: Getting count of rows in a text file -- best approach?

On 2017-04-21 10:47, Richard Kaye wrote:
> ALINES()?


Is that your answer for everything today?  lol

Nah, that feels no less dirty than my approach.  My bet is that would 
require as many (if not more) processing cycles, but of course only 
testing would show conclusively if at all.

Thanks though!
--Mike



___
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/bn4pr10mb09136d18738401672d131bb3d2...@bn4pr10mb0913.namprd10.prod.outlook.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.


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

2017-04-21 Thread mbsoftwaresolutions

On 2017-04-21 10:47, Richard Kaye wrote:

ALINES()?



Is that your answer for everything today?  lol

Nah, that feels no less dirty than my approach.  My bet is that would 
require as many (if not more) processing cycles, but of course only 
testing would show conclusively if at all.


Thanks though!
--Mike


___
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/4ac11a07810e5b7cd76b297034d26...@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.


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

2017-04-21 Thread Gianni Turri
On Fri, 21 Apr 2017 10:44:34 -0400, mbsoftwaresoluti...@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/l27kfc58h4400rk01811jbgnifgtegb...@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.


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

2017-04-21 Thread Richard Kaye
ALINES()?

--

rk
-Original Message-
From: ProfoxTech [mailto:profoxtech-boun...@leafe.com] On Behalf Of 
mbsoftwaresoluti...@mbsoftwaresolutions.com
Sent: Friday, April 21, 2017 10:45 AM
To: profoxt...@leafe.com
Subject: Getting count of rows in a text file -- best approach?

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.

tia,
--Mike


___
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/bn4pr10mb0913286d8c30227781acb000d2...@bn4pr10mb0913.namprd10.prod.outlook.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.