Counting Number of Lines

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
199542
Participant
Posts: 41
Joined: Sat Dec 29, 2007 2:42 am

Counting Number of Lines

Post by 199542 »

Hi ,
I have a requirement where I need to count number of lines in a flat file and store it in a variable ( say line_count ) .In the flat file , a trailer record will b present .In that Record , One field gives the count .If that count is equal to the line_count then the file is valid .

I can get value of line_count as follows using unix command .
line_count=`cat line_count | wc -l `

But I want it to b done in datastage . Is there any way to count number of lines in a file and store it in a variable .
From this forum , I came to know that it can b done through DSGetLinkInfo() function.
Can u plzz tell how to invoke that function ? Where to invoke that function ?
Can u plzz tell the detailed description of that as i am new to datastage .
gikjpjj
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

It makes zero sense to make DataStage read a whole file just to count it. The unix command "wc -l yourfile" is faster and more efficient for such a simple task. The API you mentioned is used to query a job after it has run and get the link information (row count) for the logic branches within the job.
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Re: Counting Number of Lines

Post by ray.wurlod »

199542 wrote:Can u plzz tell how to invoke that function ? Where to invoke that function ?
Can u plzz tell the detailed description of that as i am new to datastage .
Here at DSXchange we value professional standards of written English, much as your employer doubtless expects you to use when documenting your work or developing specification.

You are NOT new to English, so please use correct spelling.

DSXchange is NOT a mobile telephone; many of the participants are not so familiar with English that SMS-style abbreviations make any sense.


The second person personal pronoun is "you".
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply