PDA

View Full Version : Splitting file data into rows



MattCasters
01-23-2006, 04:18 AM
(Edited: posted by Anonymous in Wiki format, changed to plain text)

I have a data file in the following format:

EmpId
Year1
Salary1
Year2
Salary2
Year3
Salary3
...

I would like to split the data into rows of a table
EmpId Year1 Salary1
EmpId Year2 Salary2
EmpId Year3 Salary3
....

How do I do it ?

MattCasters
01-23-2006, 04:18 AM
Last week I created the Flattener step to do this ;-)

Grab the last kettle.jar to try it out.
(!! Java 1.5 required at the moment due to build problems on Javaforge)

If you want to "Flatten" 7 consequetive rows, specify the names of these rows.
You will get:

EmpId Year1 Salary1 Year2 Salary2 Year3 Salary3

After that, you can normalize this data using Normalizer to this format:

EmpID, 1, Year, Salary
EmpID, 2, Year, Salary
EmpID, 3, Year, Salary

Please check out the Spoon-2.2.pdf doc to find examples on how to do this.
It's not that hard to do.

All the best,

Matt