Page 1 of 1

unable to import file in required format

Posted: Tue Nov 02, 2010 10:05 pm
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?

Posted: Wed Nov 03, 2010 12:08 am
by mobashshar
have you tried TAB delimiter?

Posted: Wed Nov 03, 2010 12:23 am
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.

Posted: Wed Nov 03, 2010 7:04 am
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

Posted: Wed Nov 03, 2010 7:07 am
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.

Posted: Wed Nov 03, 2010 7:21 am
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

Posted: Wed Nov 03, 2010 7:45 am
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.

Posted: Wed Nov 03, 2010 8:07 am
by ray.wurlod
Even my answer earlier in the thread covered it reasonably fully.

Posted: Wed Nov 03, 2010 8:38 am
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