need logic to filter

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
pattemk
Participant
Posts: 84
Joined: Wed May 16, 2007 4:04 pm

need logic to filter

Post by pattemk »

Hi,

I am trying to get logic to filter out only those records from my input whose left most character starts with any alphabets or any number.

example

* xyz
abc
2 gt
@yt

i want to output only abc and 2 gt.

Please advice

thanks
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

One way - get the decimal value of the upper-cased first character and ensure it falls between either 48-57 or 65-90.
-craig

"You can never have too many knives" -- Logan Nine Fingers
anbu
Premium Member
Premium Member
Posts: 596
Joined: Sat Feb 18, 2006 2:25 am
Location: india

Post by anbu »

Use this as your transformer constraint

Code: Select all

Convert("abc..xyz0123456789","",input[1]) = ""
You are the creator of your destiny - Swami Vivekananda
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Unless the substring operators work differently in PX from Server, using input[1] would take the last character, not the first. You'd have to specify input[1,1] to get the first.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

I would prefer to use the Left() function, as it's self-documenting.

If you need to handle upper-case letters too, simply wrap the input column reference with a Downcase() function.

Code: Select all

Len(Convert("abcdefghijklmnopqrstuvwxyz0123456789", "", Downcase(Left(InLink.TheString,1))))
Here I've used the Len() function because, under the covers, 1 is used directly to represent "true" and 0 to represent "false".
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
mobashshar
Participant
Posts: 91
Joined: Wed Apr 20, 2005 7:59 pm
Location: U.S.

Post by mobashshar »

Hi,
I would use a combination of Stage Variable and Constraint to handle this issue.
First define a Stage Variable as follows: AlNumCheck=Left(AlNum(InputColumn), 1). This is going to return a True/False (1 for true and 0 for false) indicator if the first value is AlphaNumeric or not.
Second use the Constraint to pass only the rows with AlNumCheck=1.

This way you will get what you are looking for.
Hope this helps.
anbu
Premium Member
Premium Member
Posts: 596
Joined: Sat Feb 18, 2006 2:25 am
Location: india

Post by anbu »

chulett wrote:Unless the substring operators work differently in PX from Server, using input[1] would take the last character, not the first. You'd have to specify input[1,1] to get the first.
Thanks Chulett for correction
You are the creator of your destiny - Swami Vivekananda
Post Reply