Hi All,
I have csv file as given below and I need to make csv file like example below, so could you please provide me idea how to get it using DataStage job stages.
CSV File:
EmpId EmpName KeyWords
100 Rick "Update,Delete"
Basically KeyWords needs to be put into separate rows as shown in the example given below. Key words may be 2 or more, we never know. I just given example with two key words to get idea.
EmpId EmpName KeyWords
100 Rick Update
100 Rick Delete
Thank you in advance.
Thanks,
Ven
How to make rows based on one column values
Moderators: chulett, rschirm, roy
-
- Premium Member
- Posts: 22
- Joined: Wed May 08, 2013 8:38 am
- Contact:
How to make rows based on one column values
Thanks,
Venkata Gundavarapu
Venkata Gundavarapu
-
- Premium Member
- Posts: 22
- Joined: Wed May 08, 2013 8:38 am
- Contact:
Re: How to make rows based on one column values
Thank you very much for your reply.
Do you have any sample code for Transformer loop and Field function for your suggested solution.
Thanks,
Ven
Do you have any sample code for Transformer loop and Field function for your suggested solution.
Thanks,
Ven
Thanks,
Venkata Gundavarapu
Venkata Gundavarapu
Transformer
Loop Variables :
lvcnt : count(KeyWords,',')
lvfield : field(KeyWords,',',lvcnt+1)
lvLoop : if left(lvfield,1) <> '"' or right(lvfield,1) <> '"' then lvfield else if left(lvfield,1) = '"' then lvfield[2,len(lvfield)] else if right(lvfield,1) = '"' then lvfield[1,len(lvfield)-1] else SetNull()
Loop While : @ITERATION <= lvcnt + 1
Column Derivation :
Empid, EmpName, Keywords
Empid, EmpName, lvLoop
Loop Variables :
lvcnt : count(KeyWords,',')
lvfield : field(KeyWords,',',lvcnt+1)
lvLoop : if left(lvfield,1) <> '"' or right(lvfield,1) <> '"' then lvfield else if left(lvfield,1) = '"' then lvfield[2,len(lvfield)] else if right(lvfield,1) = '"' then lvfield[1,len(lvfield)-1] else SetNull()
Loop While : @ITERATION <= lvcnt + 1
Column Derivation :
Empid, EmpName, Keywords
Empid, EmpName, lvLoop
Last edited by ssnegi on Wed May 28, 2014 12:19 am, edited 1 time in total.
-
- Premium Member
- Posts: 22
- Joined: Wed May 08, 2013 8:38 am
- Contact:
How to make rows based on one column values
Thank you very much. the sample code is working fine for me.
Thanks,
Ven
Thanks,
Ven
Thanks,
Venkata Gundavarapu
Venkata Gundavarapu