I have the following list as an example:
Original list:
mylist{0}.attr1 = a1
mylist{0}.attr2 = a2
mylist{0}.attr3 = a3
mylist{1}.attr1 = b1
mylist{1}.attr2 = b2
mylist{1}.attr3 = b3
mylist{2}.attr1 = c1
mylist{2}.attr2 = c2
mylist{2}.attr3 = c3
mylist{3}.attr1 = d1
mylist{3}.attr2 = d2
mylist{3}.attr3 = d3
mylist{4}.attr1 = e1
mylist{4}.attr2 = e2
mylist{4}.attr3 = e3
Â
I want to regroup this list elements by recreating multiple lists by grouping the elements into 2 pairs while taking into account the previous element index as follows:
Â
New regrouping of elements:
lstGroup1{0}.attr1 = a1
lstGroup1{0}.attr2 = a2
lstGroup1{0}.attr3 = a3
lstGroup1{1}.attr1 = b1
lstGroup1{1}.attr2 = b2
lstGroup1{1}.attr3 = b3
Â
lstGroup2{0}.attr1 = b1
lstGroup2{0}.attr2 = b2
lstGroup2{0}.attr3 = b3
lstGroup2{1}.attr1 = c1
lstGroup2{1}.attr2 = c2
lstGroup2{1}.attr3 = c3
Â
lstGroup3{0}.attr1 = c1
lstGroup3{0}.attr2 = c2
lstGroup3{0}.attr3 = c3
lstGroup3{1}.attr1 = d1
lstGroup3{1}.attr2 = d2
lstGroup3{1}.attr3 = d3
Â
lstGroup4{0}.attr1 = d1
lstGroup4{0}.attr2 = d2
lstGroup4{0}.attr3 = d3
lstGroup4{1}.attr1 = e1
lstGroup4{1}.attr2 = e2
lstGroup4{1}.attr3 = e3
I tried creating a custom looping transformer using a Sampler, but not succeeding, may be a Python code can be easier to do the task..please help.
Note the challenge is the original list length can be varied (dynamic) could be 2, 3, 4, ..50+ etc