QualityStage equivalent of DCount function

Infosphere's Quality Product

Moderators: chulett, rschirm

Post Reply
ejazsalim
Premium Member
Premium Member
Posts: 51
Joined: Wed Apr 09, 2003 6:42 am
Location: VA, USA

QualityStage equivalent of DCount function

Post by ejazsalim »

Is there an equivalent of the datastage function DCount in QualityStage.

What I am trying to do is standardize a file and then look for the number of occurrence of a particular classification.

eg : F+W+IWF+CFF
My answer should be 4, Since I am looking for all "F" in the pattern.

I am trying to avoid putting in a DS job if I can

Thanks
Ejaz
jhmckeever
Premium Member
Premium Member
Posts: 301
Joined: Thu Jul 14, 2005 10:27 am
Location: Melbourne, Australia
Contact:

Post by jhmckeever »

Hi ejazsalim,

Off the top of my head, I don't believe the 'function' you're looking for is available in QualityStage Pattern Action Language, however you could build a set of patterns to look for hard-coded numbers of tokens:

E.g. Given an output field CN (count) defined in your dictionary ...

Code: Select all

** | F | **
COPY "1" {CN} 

** | F | ** | F | **
COPY "2" {CN} 

** | F | ** | F | ** | F | **
COPY "3" {CN} 

** | F | ** | F | ** | F | ** | F | **
COPY "4" {CN} 

etc.
You'd obviously need to add the logic to prevent double-matching of patterns, but I'm sure you see what I'm getting at. Very far from an elegant solution, but would work within certain limits.

A better solution would be to use an Investigate stage, then push the .PAT file through a shell script (by defining a Program Stage) which would return the number of instances of your required token on each line.

... but it would still be far easier to use DataStage for all this. :? Any particular reason why you're avoiding doing this in DS?

HTH,
J.
<b>John McKeever</b>
Data Migrators
<b><a href="https://www.mettleci.com">MettleCI</a> - DevOps for DataStage</b>
<a href="http://www.datamigrators.com/"><img src="https://www.datamigrators.com/assets/im ... l.png"></a>
ejazsalim
Premium Member
Premium Member
Posts: 51
Joined: Wed Apr 09, 2003 6:42 am
Location: VA, USA

Post by ejazsalim »

Thanks J
well the only reason to avoid DS is that I am trying to build a lightweight solution using only QS as this is supposed to run on individual laptops for users with minimum training. I am just trying to avoid training my business folks on 2 tools
jhmckeever wrote:Hi ejazsalim,

Off the top of my head, I don't believe the 'function' you're looking for is available in QualityStage Pattern Action Language, however you could build a set of patterns to look for hard-coded numbers of tokens:

E.g. Given an output field CN (count) defined in your dictionary ...

Code: Select all

** | F | **
COPY "1" {CN} 

** | F | ** | F | **
COPY "2" {CN} 

** | F | ** | F | ** | F | **
COPY "3" {CN} 

** | F | ** | F | ** | F | ** | F | **
COPY "4" {CN} 

etc.
You'd obviously need to add the logic to prevent double-matching of patterns, but I'm sure you see what I'm getting at. Very far from an elegant solution, but would work within certain limits.

A better solution would be to use an Investigate stage, then push the .PAT file through a shell script (by defining a Program Stage) which would return the number of instances of your required token on each line.

... but it would still be far easier to use DataStage for all this. :? Any particular reason why you're avoiding doing this in DS?

HTH,
J.
jhmckeever
Premium Member
Premium Member
Posts: 301
Joined: Thu Jul 14, 2005 10:27 am
Location: Melbourne, Australia
Contact:

Post by jhmckeever »

Hi ejazsalim,

I'll leave it to others to discuss the merits of stand alone DataStage on a laptop. Assuming those laptops are connected to your network then remember that as well as embedding a QualityStage job inside DataStage, you could also (in theory - although I've never tried it) invoke a DataStage job from within QualityStage by defining a Program Stage around the 'dsjob' command. This wouldn't require your users to know very much about DataStage as the interaction would be effectively hidden. DataStage would just operate on the QualityStage output and produce one or more sequential files just like any other QualityStage stage.

As noted above, my first approach would be an Investigate stage with the resulting PAT file pushed through something like an awk script.

HTH,
John.
<b>John McKeever</b>
Data Migrators
<b><a href="https://www.mettleci.com">MettleCI</a> - DevOps for DataStage</b>
<a href="http://www.datamigrators.com/"><img src="https://www.datamigrators.com/assets/im ... l.png"></a>
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Since your sitting on Unix, write a small awk script to do it. It will be the easiest for the business folks.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Yeah, right. No doubt "on individual laptops" means they're running Linux.
:P
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

The quick DSGuru2B jumped over ahead of himself, yet again. But why? :wink:
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
jhmckeever
Premium Member
Premium Member
Posts: 301
Joined: Thu Jul 14, 2005 10:27 am
Location: Melbourne, Australia
Contact:

Post by jhmckeever »

... and I assumed every right-minded individual had MKS/Cygwin installed!?

... either that or you really enjoy pushing data through VBScript/WScript.
<b>John McKeever</b>
Data Migrators
<b><a href="https://www.mettleci.com">MettleCI</a> - DevOps for DataStage</b>
<a href="http://www.datamigrators.com/"><img src="https://www.datamigrators.com/assets/im ... l.png"></a>
Post Reply