View previous topic :: View next topic
|
Author |
Message |
sudalaimani
New User
Joined: 08 Apr 2009 Posts: 2 Location: chennai, india
|
|
|
|
What is the REXX command to get the total number of records in a
file. Please suggest.. |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
rexx is not the most practical tool for such a task...
search the forums for a sort approach ( syncsort/dfsort ) |
|
Back to top |
|
|
Aaru
Senior Member
Joined: 03 Jul 2007 Posts: 1287 Location: Chennai, India
|
|
|
|
Sudalaimani,
Quote: |
What is the REXX command to get the total number of records in a
file. Please suggest.. |
You can read the file into a stem variable say X and X.0 will have the count of the number of records. |
|
Back to top |
|
|
prino
Senior Member
Joined: 07 Feb 2009 Posts: 1306 Location: Vilnius, Lithuania
|
|
|
|
Aaru wrote: |
Quote: |
What is the REXX command to get the total number of records in a
file. Please suggest.. |
You can read the file into a stem variable say X and X.0 will have the count of the number of records. |
This is a stupid suggestion given that the OP has given no indication about the potential number of records in the file. Doing an EXECIO on a file with 10 records is not a problem, doing the same on a file with 1,000,000 records is insane! |
|
Back to top |
|
|
Aaru
Senior Member
Joined: 03 Jul 2007 Posts: 1287 Location: Chennai, India
|
|
|
|
Prino,
Then
Quote: |
What is the REXX command to get the total number of records in a
file |
???? |
|
Back to top |
|
|
prino
Senior Member
Joined: 07 Feb 2009 Posts: 1306 Location: Vilnius, Lithuania
|
|
|
|
Your
Aaru wrote: |
You can read the file into a stem variable say X and X.0 will have the count of the number of records. |
implies using EXECIO, which is a very bad suggestion on a file of unknown size. |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
REXX isn't the best IO handler for large files. I would steer away from a solution using REXX. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
File processing (of large or unknown size files) in rexx is another of the things that "can be done", but should not be done. . .
Quote: |
REXX isn't the best IO handler for large files |
Ah, the gift of understatement. . . |
|
Back to top |
|
|
MBabu
Active User
Joined: 03 Aug 2008 Posts: 400 Location: Mumbai
|
|
|
|
Rexx doesn't have native I/O so it doesn't make any sense to say that Rexx is a bad choice for this.
EXECIO, which is an external call, might be a bad or good choice depending on many factors like record size, frequency of use, need for a quick solution, etc. But you can also use Rexx to call any number of other programs. For example, you can Call SORT from Rexx and have it do the count, then use EXECIO to read the listing. Easy to code, quick to run, perfectly adaquate, and... its Rexx (as much as usiing EXECIO is, anyway).
you could also call ISPF services like LMGET, or call IEBGENER to copy to DUMMY and read the listing, etc, etc. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Opinions vary. . .
If it didn't make sense, i'd not have posted same.
Quote: |
Rexx doesn't have native I/O so it doesn't make any sense to say that Rexx is a bad choice for this. |
Precisely because it doesn't have any "native i/o", and the number of new rexx'ers that seem to get completely enamored about EXECIO (and that population is growing), i say for much of our audience, rexx is a bad choice to copy large (or unknown) volume files.
For people who do know how to invoke other better suited utilities, fine, but for the ones who only know execio, best not done this way.
These are the same folks who get the 100 record test running perfectly and then "go live" and have to deal with running out of memory, running out of cpu cycles, running "forever" and on and on. . . |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
Quote: |
For example, you can Call SORT from Rexx and have it do the count, then use EXECIO to read the listing |
Why not execute the sort "directly"? |
|
Back to top |
|
|
Pedro
Global Moderator
Joined: 01 Sep 2006 Posts: 2547 Location: Silicon Valley
|
|
|
|
Quote: |
Why not execute the sort "directly"?
|
Not sure what you mean by "directly", but a key point of this thread is that rexx is not particular good at I/O and it becomes more obvious for a large number of records.
My suggestion is to use LISTDSI to determine the number of blocks and cylinders and such. If it is small enough you can read the records. If it is too large, just compute an estimate by using the number of cylinders, the size of the blocks, and the lrecl to guess how many records there might be. |
|
Back to top |
|
|
MBabu
Active User
Joined: 03 Aug 2008 Posts: 400 Location: Mumbai
|
|
|
|
arcvns wrote: |
Why not execute the sort "directly"? |
Because getting the result is then a manual effort of reading the listing. Since the question is about Rexx, I assume that the intent is to use the number for some other automated purpose.
Pedro, just to belabor the point, you are talking about EXECIO which is one way to do I/O in rexx. It is not efficient for large numbers of records. But there are other ways to do I/O including calling other programs like sort, ispf, iebgener, some non-ibm function packages, homegrown function packages, and even CLISTs which can sometimes outperform Rexx for specific purposes. Rexx itself isn't terribly fast (at least on z/OS - Object Rexx on a PC is very fast) and neither is EXECIO, but it isn't fair to say that Rexx is bad at I/O. The Rexx language doesn't do file I/O -- external programs like EXECIO do it and some are better for certain tasks than others. Of course, the original question is a special case because all that is being done is counting so the interpreter never needs to see the contents of the records. |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
Quote: |
Because getting the result is then a manual effort of reading the listing. Since the question is about Rexx, I assume that the intent is to use the number for some other automated purpose. |
Why not store and parse the output from the SYSOUT DDname ? |
|
Back to top |
|
|
MBabu
Active User
Joined: 03 Aug 2008 Posts: 400 Location: Mumbai
|
|
|
|
That's exactly what I was suggesting. Using a utility like sort or IEBGENER, the output is going to come from somewhere in a file (listing or formatted output), and you can use EXECIO to read just that small file. |
|
Back to top |
|
|
|