String Parsing

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

varshanswamy
Participant
Posts: 48
Joined: Thu Mar 11, 2004 10:32 pm

Re: String Parsing

Post by varshanswamy »

How do I further use the pivot function I am unable to follow. Could you please help on this
Sunshine2323 wrote:Hi Varsha,

You can use the Convert function to convert all the "&" to ","
So after conversion your data will look as follows

1,A=B,C=D,E=F,G=H
2,L=M,G=H

Then you can use the pivot to pivot the data and get the result in the required format

1, A=B
1, C=D
1, E=F
1, G=H
2, L=M
2, G=H
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

There is no pivot function. There is a Pivot stage. It has its own manual and its own help, and is quite easy to use. Indeed, an earlier poster provided all the information you need.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
varshanswamy
Participant
Posts: 48
Joined: Thu Mar 11, 2004 10:32 pm

Post by varshanswamy »

I am still unable to get the required result through the pivot stage as mentioned, I did try using the pivot stage, in the derivation of the Output Tab of pivot I am uable to get the required result.
If I put the value of the key, string in the derivation I get the key in the first row and the entire string in the next row.
Sunshine2323
Charter Member
Charter Member
Posts: 130
Joined: Mon Sep 06, 2004 3:05 am
Location: Dubai,UAE

Re: String Parsing

Post by Sunshine2323 »

varshanswamy wrote:How do I further use the pivot function I am unable to follow. Could you please help on this
Sunshine2323 wrote:Hi Varsha,

You can use the Convert function to convert all the "&" to ","
So after conversion your data will look as follows

1,A=B,C=D,E=F,G=H
2,L=M,G=H

Then you can use the pivot to pivot the data and get the result in the required format

1, A=B
1, C=D
1, E=F
1, G=H
2, L=M
2, G=H

Lets go one step at a time,

Step1) Have you used the Convert function and got the above mentioned result?

After you convert the data pass it to a Sequential file.

Now try reading the data in a newSequential file with delimiter as ","

Lets say your View Data looks like this,
Key Field1 Field2 Field3 Field4
1 A=B C=D E=F G=H
2 L=M G=H

Step2) Pass the data through a Pivot. For more help on Pivot stage you can read Pivot.pdf
In the output tab of the Pivot stage, enter only 2 columns

ColumnName Derivation
Key Key
Field Field1,Field2,Field3,Field4

Now dump this Output to sequential File.

Step 3) You will get null values where Field3 and Filed4 are null. You can pass the data through a Transformer before dumping it to a Sequential file with the constraint Not(IsNull(Field))

And you will get the required result. :)

Hope this helps.
Warm Regards,
Amruta Bandekar

<b>If A equals success, then the formula is: A = X + Y + Z, X is work. Y is play. Z is keep your mouth shut. </b>
--Albert Einstein
varshanswamy
Participant
Posts: 48
Joined: Thu Mar 11, 2004 10:32 pm

Re: String Parsing

Post by varshanswamy »

I have problem here, if there are 2 ampersands in one string and 4 ampersands in another string it is creating a problem for me, when I read the file in step 2 it is overwritng the first line with the second line, that is I get only one row having Field1 Field2 Field3 and Field4

Sunshine2323 wrote:
varshanswamy wrote:How do I further use the pivot function I am unable to follow. Could you please help on this
Sunshine2323 wrote:Hi Varsha,

You can use the Convert function to convert all the "&" to ","
So after conversion your data will look as follows

1,A=B,C=D,E=F,G=H
2,L=M,G=H

Then you can use the pivot to pivot the data and get the result in the required format

1, A=B
1, C=D
1, E=F
1, G=H
2, L=M
2, G=H

Lets go one step at a time,

Step1) Have you used the Convert function and got the above mentioned result?

After you convert the data pass it to a Sequential file.

Now try reading the data in a newSequential file with delimiter as ","

Lets say your View Data looks like this,
Key Field1 Field2 Field3 Field4
1 A=B C=D E=F G=H
2 L=M G=H

Step2) Pass the data through a Pivot. For more help on Pivot stage you can read Pivot.pdf
In the output tab of the Pivot stage, enter only 2 columns

ColumnName Derivation
Key Key
Field Field1,Field2,Field3,Field4

Now dump this Output to sequential File.

Step 3) You will get null values where Field3 and Filed4 are null. You can pass the data through a Transformer before dumping it to a Sequential file with the constraint Not(IsNull(Field))

And you will get the required result. :)

Hope this helps.
T42
Participant
Posts: 499
Joined: Thu Nov 11, 2004 6:45 pm

Post by T42 »

Do your own job, or pay someone to do it for you. I refuse to help people who expect the complete code, and refuses to understand what is going on here. There are wonderful advices that a person who is capable of using PX can easily utilize to create a job.

Do what you are hired to do, or pay someone else to do it for you.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

T42 & Varshanswamy,

I've stopped responding to this thread for the same reason(s). It seems that an answer that almost works and needs only a basic understanding of string manipulation to modify so that it performs according to wishes is too much work - the only acceptable response for him/her is something that only needs to be plugged in to work. This is a public and free forum for information exchange and mutual assistance and cannot survive with an attitude like that.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

On the other hand, there are quite a few self-employed consultants and service providers here who would be happy to SELL a customised and working solution. This is what T42 was getting at with "pay someone".
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