Iterate through a set of column

Hello,
i’m a newbie on EasyMorph (and i’m french sorry for my english).

I want to split a file by a group of column and i have no success at this time with iterate column.

My file is like this

Header :
DataA ; DataB ; DataC ; Cur1 ; Cur2 ; Cur3 ; Cur(…n) ; Value1 ; Value2 ; Value3 ; Value(…n)

And i want to have this result
Header :
DataA ; DataB ; DataC ; Cur ; Value
All line in the file with this structure :
DataA ; DataB ; DataC ; Cur1 ; Value1
DataA ; DataB ; DataC ; Cur2 ; Value2
DataA ; DataB ; DataC ; Cur3 ; Value3

DataA ; DataB ; DataC ; Cur(n) ; Value(n)

I could fix n to 20 and derive 20 times but it’s not a good way

Is there an easy way with EM to do that ?

Hello and welcome to the Community!

Yes, it can easily be done in EasyMorph using actions for splitting delimited values and pivoting. See the example below.

split-and-pivot.morph (3.1 KB)

Thank you so much,
i think it’s a good way but there’s a lot of datas in the file. I have made 2 samples files for better understanding.in.csv (1.3 KB) Out.csv (437 Bytes)


I have made a try like this and another one with iterate column. the first works but it’s hardcoded and the second one don’t work because I couldn’t pass a set of column to another module.

I still don’t think you need an “Iterate column” here. The “Iterate column” action is needed when the same calculation needs to be applied to every column (except selected excluded). Here it’s not the case.

Unpivoting and re-pivoting would do the job perfectly. Just remember to keep rows properly enumerated (i.e. provided with distinct IDs) for the final re-pivoting to work correctly as it uses the “Any” aggregation. Here you go:

block-pivot.morph (4.8 KB)

2 Likes

Whaou !! thanks a lot, very impressive.