A script can be written that will test for the different variations in a column name, and then change the name to the standard form.
Once in the standard form, as you describe the names, the following script takes the standard form
And convert it into the new form for the table
names default to here(1);
dt = new table("Example",
add rows(20),
New column("Task 1 arm", set each value(random integer(1,100))),
New column("Task 1 leg", set each value(random integer(1,100))),
New column("Task 2 arm", set each value(random integer(1,100))),
New column("Task 2 leg", set each value(random integer(1,100))),
New column("Task 3 arm", set each value(random integer(1,100))),
New column("Task 3 leg", set each value(random integer(1,100))),
New column("Task 3 face", set each value(random integer(1,100)))
);
dt << new column("Row", set each value(Row()));
dtStack = dt << Stack(
columns(
:Task 1 arm, :Task 1 leg, :Task 2 arm, :Task 2 leg, :Task 3 arm, :Task 3 leg,
:Task 3 face
),
Output Table( "Stack" )
);
dtStack << new column("Body Part", character, formula( word(-1, :label, " ")));
dtStack << new column( "Task", character, formula( substr(:Label, 1 ,length(:label)-length(:body part)-1)));
dtFinal = dtStack << Split(
Split By( :Task ),
Split( :Data ),
Group( :Body Part, :row ),
Output Table( "Final" ),
Remaining Columns( Drop All ),
Sort by Column Property
);
dtFinal << Sort( By(:row, :Body Part), Replace Table(1));
dtFinal << delete columns(:row);
dt << delete columns(:row);
close( dtStack, nosave );
Jim