Post a reply

Write your message and submit

Options

Click in the dark area of the image to send your post.

Go back

Topic review (newest first)

shong
2009-12-17 10:04:51

Hello
Hava you successfully installed tUnpivotRow component to TOS3.2.2? If so, it is easy to get the result like this:
1|t
1|t
1|t
1|t
2|t
2|s
2|s
2|t
After then, define a routine to generat sequence number for each id and add a new column on tMap.
For examle,
in.csv:

1|t
1|t
1|t
1|t
2|t
2|s
2|s
2|t

Go to Repository-->Code-->Routine, right click on Routine and create a new routine called:

Code:

// template routine Java
package routines;

public class F9259 {

    static java.util.Map<Integer, Integer> map = new java.util.HashMap<Integer, Integer>();
    static Integer current;

    public static int getSeqNumber(int id) {
        Integer lastValue = (Integer) map.get(id);
        if (lastValue != null) {
            current = lastValue + 1;
            map.put(id, current);
        } else {
            current = 1;
            map.put(id, current);
        }
        return current;
    }
}

On tMap, add new column and call routine. (see my screenshots)

result:

Code:

Starting job forum9259 at 17:02 17/12/2009.

[statistics] connecting to socket on port 3472
[statistics] connected
.--+-----+---.
| tLogRow_1  |
|=-+-----+--=|
|id|value|num|
|=-+-----+--=|
|1 |t    |1  |
|1 |t    |2  |
|1 |t    |3  |
|1 |t    |4  |
|2 |t    |1  |
|2 |s    |2  |
|2 |s    |3  |
|2 |t    |4  |
'--+-----+---'

[statistics] disconnected
Job forum9259 ended at 17:02 17/12/2009. [exit code=0]

Best regards

          shong

r.hills
2009-12-16 16:43:30

it seems the version of TOS which I am using (3.2.2) doesnt support this add on, or I simply dont know how to use it properly.
Thus, if someone can point me in the direction of a working module for pivot table csv's or suggest what I may be doing wrong with the file above (maybe I just installed it wrong... though I believe not), that would be greatly appreciated.

r.hills
2009-12-16 15:58:29

i have now found this "extension"
http://talendforge.org/exchange/tos/ext … hp?eid=148

if anyone can suggest anything better that would still be appreciated, though it seems this does what we require so I shall try to install it now.

r.hills
2009-12-16 15:46:15

I have the following format csv

id,first,second,third,fourth
1,t,t,t,t
2,t,s,s,t

Or something like that in any case
in mysql I want to see the following rows
id|value|number
1|t|1
1|t|2
1|t|3
1|t|4
2|t|1
2|s|2
2|s|3
2|t|4

I hope that made sense...
Is there some module which exists already to do such a transform or do I need to write something myself to do this?
thank you.

Board footer

Powered by FluxBB