DataStage Scenario Based Question – Separate Numbers and Alphabets

DATASTAGE-SCENARIO-BASED-QUESTION-AND-SOLUTION

DataStage scenario based question:

There is a column having both numbers and alphabet, the requirement is to separate all the numbers in one column and alphabet in other column.

Input File(Data)

Data
1Da4ta3St1age4
I34B09M67
67I5nfo45sp7eh9er0e
3W4in67gs89of06tec23hn56ol77ogy44

Output File(Alpha,Number)

Alpha,Number
IBM,340967
Wingsoftechnology,3467890623567744
DataStage,14314
Infospehere,67545790

Solution:

First read the input data in sequential file stage:

scenarios-alphanumerics-input-data

Next pass the input data to transformer stage. We can separate alphabets and numeric using 2 stage variables in transformer stage.

Create stage variables like below:

svAlpha: Convert("0123456789","",lnk_alphanumerics.MixData)

svNumerics: Convert(svAlpha,"",lnk_alphanumerics.MixData)

Read also: What is a Schema File in DataStage?

Assign these stage variables to output columns like below.

svAlpha = Alpha

svNumerics = Number

datastage-scenarios-alphanumerics-transformer

Final job design would be:
datastage-job-design-scenarios-alphanumerics

Compile and run the job.

datastage-final-job-design-scenarios-alphanumerics

We will get output like below.

scenarios-alphanumerics-output-data

Comments

comments

Leave a Reply