IFS Record Count

pts.
Tags:
RPG
How can I retrieve the record count of a .csv file in the IFS? We're at V5R2. I would like a way to do it in either RPGLE or CL, but am open to other suggestions as well.

Answer Wiki

Thanks. We'll let you know when a new response is added.

A stream file has no notion of records; thus there is no way to determine a number of records. What you can do is write a program that reads the file and count the number of carriage returns a/o linefeeds; that is probably what you would consider to be the record separator in a .csv file.

Joep Beckeringh

Discuss This Question: 4  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Fanbot
    Another alternative is to create a temp file length X bytes. Then use CPYFRMPCD and copy data from CSV file to file. DSPFD or usr RTVMBRD retrieving the number of records.
    0 pointsBadges:
    report
  • TennPgmr
    You should be able to load the file into a workfile on the AS400 then retrieve the number of records in that file either by writing a simple program or looking at the output from DSPFD.
    0 pointsBadges:
    report
  • Stepheno
    I've found a way to do it without loading the records to a database file. Actually, I found the answer online. The following command will return the record count of a file in the ifs. qsh cmd('cat /testdir/test.csv | wc -l')
    0 pointsBadges:
    report
  • TomLiotta
    ...use CPYFRMPCD... The CPYFRMPCD command can't be used for the vast majority of streamfiles. It should be avoided since it only applies to the old and almost completely obsolete /QDLS file system. Further, it requires a profile that has been enrolled in the system directory. You should be able to load the file into a workfile... For small streamfiles, that might be useful. But it's risky for large files and extremely wasteful. Copy GB-sized streamfiles with unpredictable line lengths into fixed-length database files can blow your system space in DASD-constrained systems. If you can't predict line-lengths, you need a database file with record lengths big enough to hold the longest line. Otherwise, you'll get inaccurate results due to line-wrap. The QSH suggestion is simplest. However, joepbeckeringh's mention of line delimiters is correct. If you don't know how lines are terminated, you have no way to "count" lines. Tom
    125,585 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following