Create new row for each location

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
pavan_test
Premium Member
Premium Member
Posts: 263
Joined: Fri Sep 23, 2005 6:49 am

Create new row for each location

Post by pavan_test »

Hi,

I am using infosphere datastage v8.7 on aix.

can someone please suggest me how can I get expected output using datastage.

my input data:

id,id2,location
1, k12, CA, WA, NY
2,K8,VA,TX

expected output:

id,id2,location
1,k12,CA
1,k12,WA
1,k12,NY
2,k8,VA
2,k8,TX
rkashyap
Premium Member
Premium Member
Posts: 532
Joined: Fri Dec 02, 2011 12:02 pm
Location: Richmond VA

Post by rkashyap »

Based on the sample input and output, I believe that requirement is to horizontally pivot data. See Horizontal Pivot Example using Pivot Enterprise Stage.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Your input needs to have sufficient location columns defined to cover all possibilities in the data.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
pavan_test
Premium Member
Premium Member
Posts: 263
Joined: Fri Sep 23, 2005 6:49 am

Create new row for each location

Post by pavan_test »

The horizontal pivot stage appears to be reading data from 3 separate column as below

Table 1. Input data for a simple horizontal pivot operation


https://www-01.ibm.com/support/knowledg ... ample.html

However my data is comma separated and its all in 1 column (location).

when I designed the job using pivot enterprise, under pivot properties I defined as location. the output still the same as input.

my input data:

id,id2,location
1, k12, CA, WA, NY
2,K8,VA,TX

expected output:

id,id2,location
1,k12,CA
1,k12,WA
1,k12,NY
2,k8,VA
2,k8,TX

Thanks
rkashyap
Premium Member
Premium Member
Posts: 532
Joined: Fri Dec 02, 2011 12:02 pm
Location: Richmond VA

Post by rkashyap »

Before data is pivoted, use either Column Import stage or Tranformer's FIELD function to derive multiple Location columns ('LOC1', 'LOC2' ...) from 'LOCATION'.
ShaneMuir
Premium Member
Premium Member
Posts: 508
Joined: Tue Jun 15, 2004 5:00 am
Location: London

Post by ShaneMuir »

If your input is variable as to the number of columns for location, but the first two identifier columns are static, then just use a transformer.

Separate the first 2 columns using the field function.
Get a count of the remaining delimiters and use the loop functionality to output a row for each delimited value.
Post Reply