How to achieve other than Pivot
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 92
- Joined: Wed Mar 05, 2008 4:09 am
- Location: chennai
- Contact:
How to achieve other than Pivot
Hi Experts,
I have requirement
Input:
a b c
1 10 20
2 30 40
Output Required:
a Computed_col(E)
1 10
1 20
2 30
2 40
How to achieve these other than pivot stage.
Can anyone help me on this?
Thanks in advance for your reply! [/b]
I have requirement
Input:
a b c
1 10 20
2 30 40
Output Required:
a Computed_col(E)
1 10
1 20
2 30
2 40
How to achieve these other than pivot stage.
Can anyone help me on this?
Thanks in advance for your reply! [/b]
pradeep.v
-
- Participant
- Posts: 92
- Joined: Wed Mar 05, 2008 4:09 am
- Location: chennai
- Contact:
Hi
Hi Mahadev,mahadev.v wrote:Any specific reason why you don't want to use the Pivot stage? A custom Build Op stage can be used, but involves a lot of coding.
No reason behind that
Whats that Custom Op?
Any Idea how we can perform in Transformer.
Thanks for the reply
pradeep.v
pradeep,
I guess it can be possible through funnel stage.
From transformer/copy get two links.
Propogate the fields "a" and "b" in 1st link.
Propogate the fields "a" and "c" in 2nd link.
Then combine the records through funnel stage. But make sure that you rename one of the field name as "b" or "c" (otherwise funnel stage will not work properly as it expects same metadata from both the links. ).
I guess it can be possible through funnel stage.
From transformer/copy get two links.
Propogate the fields "a" and "b" in 1st link.
Propogate the fields "a" and "c" in 2nd link.
Then combine the records through funnel stage. But make sure that you rename one of the field name as "b" or "c" (otherwise funnel stage will not work properly as it expects same metadata from both the links. ).
Ping me if I am wrong...
-
- Participant
- Posts: 92
- Joined: Wed Mar 05, 2008 4:09 am
- Location: chennai
- Contact:
-
- Participant
- Posts: 92
- Joined: Wed Mar 05, 2008 4:09 am
- Location: chennai
- Contact:
Hi Pradeep,
I can think of a way to do this - though it is not the exact pivoting method.
You dint mention what is the delimiter here.
From your input read the entire record as one column.
say your first record is 1 10 20 30 40.
( i assume delimiter is space)
In the transformer stage, you can get the first value 1 and then replace each of the delimiter ' ' with ' 1,'
so your string looks like 1 1,10 1,20 1,30 1,40
Now, you can replace the space with newline char and write the record 1,10 1,20 1,30 1,40 to output file.
* If you want to further process the resulted records, you have to do it in another job. ( where record delimiter is newline and column delimiter is comma)
I can think of a way to do this - though it is not the exact pivoting method.
You dint mention what is the delimiter here.
From your input read the entire record as one column.
say your first record is 1 10 20 30 40.
( i assume delimiter is space)
In the transformer stage, you can get the first value 1 and then replace each of the delimiter ' ' with ' 1,'
so your string looks like 1 1,10 1,20 1,30 1,40
Now, you can replace the space with newline char and write the record 1,10 1,20 1,30 1,40 to output file.
* If you want to further process the resulted records, you have to do it in another job. ( where record delimiter is newline and column delimiter is comma)
-
- Participant
- Posts: 92
- Joined: Wed Mar 05, 2008 4:09 am
- Location: chennai
- Contact:
Pradeep
You never mentioned about it being a file or perhaps i missed it, if you were expecting to read them as column b, c, d, e ...so on.... with 'a' being your key column
i mean would it be like
a, b, c, null, null, null, null
a, b, c, d, e, null, null
a, b, c, null, null, null, null
a, b, c, d, e, f, g, h
Because i guess you would need to specify a metadata on your source stage??
if not would you be reading them as a, concatenated values b??
that case... you can detemine the number of times a delimiter occurs between these values in column 'b' and feed that into a stage variable. and loop it that number of times using a combination of stage variables based on that against your key column 'a'.
You never mentioned about it being a file or perhaps i missed it, if you were expecting to read them as column b, c, d, e ...so on.... with 'a' being your key column
i mean would it be like
a, b, c, null, null, null, null
a, b, c, d, e, null, null
a, b, c, null, null, null, null
a, b, c, d, e, f, g, h
Because i guess you would need to specify a metadata on your source stage??
if not would you be reading them as a, concatenated values b??
that case... you can detemine the number of times a delimiter occurs between these values in column 'b' and feed that into a stage variable. and loop it that number of times using a combination of stage variables based on that against your key column 'a'.
The technique that Pagadrai mentioned is discussed in this FAQ post by the way.
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers