Table conversion

Hello,

I somehow get stuck with the following problem. I have a long two-column table with music tracks and a variable numer of information for each track after each TrackID row like

Key        Value

TrackID     1

Name    name1

Artist        artist1

TrackID    2

Name    name2

Artist        artist2

Album    album1

I want to convert it to table like below to ultimately transform it with a pivot node to a more database-like table.

Key        Value    TrackID

TrackID     1        1

Name    name1    1

Artist        artist1    1

TrackID    2        2

Name    name2    2

Artist        artist2    2

Album    album1    2

I tried to create a workflow variable which I would overwrite in a loop if a new track ID appears and append this workflow variable in the TrackID column but somehow I am not able to overwrite the workflow variable.

Any idea how to achieve this in a simple way?

Jerry

 

 

I had a similar problem last week where I used to Java Snippet (simple):

if ($Key$.equals("TrackID")) {
    s = $Value$;
}
return s;

as method body and s defined in the Global Variable Definition as String s; in the dialog's configuration. You only need to convert the resulting String column "TrackID" into a integer, using the String to Number node.

Thanks a lot Gabriel, it works like a charm.

Merry Christmas

Jerry