unable to import file in required format

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
raji33
Premium Member
Premium Member
Posts: 151
Joined: Thu Sep 23, 2010 9:21 pm
Location: NJ

unable to import file in required format

Post by raji33 »

Hi All,

Iam importing a txt file the sample input is

name: roxy
place: chili
job_type: emp
status: active
block: A
manager: vick
duration: 2

now i want output as

name place job_type status block manager duration
roxy chili emp active A vick 2

i tried with delimiter : but iam not getting required output, Any one encountered the same issue?
mobashshar
Participant
Posts: 91
Joined: Wed Apr 20, 2005 7:59 pm
Location: U.S.

Post by mobashshar »

have you tried TAB delimiter?
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

You will need to read the file as if it contains two fields with ":" as the delimiter then, in a Transformer stage, direct values into the appropriate columns depending on the value of the field name. Use stage variables so that you only change the affected column in each case.
Set another output column to contain a unique key for each record (increment each time "name:" occurs) and use a downstream Aggregator stage to preserve the last record in each group grouped by that key.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
raji33
Premium Member
Premium Member
Posts: 151
Joined: Thu Sep 23, 2010 9:21 pm
Location: NJ

Post by raji33 »

Hi ray,

but if i do so then i will get only two fields but i need out in this way

name place job_type status block manager duration

roxy chili emp active A vick 2


This is my input

name: roxy
place: chili
job_type: emp
status: active
block: A
manager: vick
duration: 2
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Ray's suggestion gives you a structured input where the 2nd field contains the values you want. Now all you need to do is a vertical pivot (asked & answered many times here in the forum) and you have your result.
raji33
Premium Member
Premium Member
Posts: 151
Joined: Thu Sep 23, 2010 9:21 pm
Location: NJ

Post by raji33 »

Hi Arnd,

What ever u suggested is exactly what iam looking for but iam using server edition can you please suggest me how to achieve this in server edition.

Thanks
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Again, this has been covered many times. In your case you would use stage variables. You would add the ColB values to a stage variable until such time as a new colA value of "name" occurs, then output the string from the transform stage.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Even my answer earlier in the thread covered it reasonably fully.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
raji33
Premium Member
Premium Member
Posts: 151
Joined: Thu Sep 23, 2010 9:21 pm
Location: NJ

Post by raji33 »

Hi ray,

"in a Transformer stage, direct values into the appropriate columns depending on the value of the field name. ... "

To the above suggestion if we take 2 fieldslike

field1 field2

name roxy
place chili
job_type emp
status active
block A
manager vick
duration 2

How can we direct this to appropriate colums ?sorry for taking your time
Post Reply