Warning: Includes some dodgy code... can definitely be improved! I was asked for help restructuring a huge Excel table and this was the result.
We had an Excel table of the format shown in the Input Table. It could have any number of experiments, subjects and trials (unique values under ExperimentsName
, Subject
and Trial
columns) in addition to any number of score IDs (ScoreX
columns). In the example below there are 3 experiments, 3 subjects, 4 trials and N score columns. This needed to be transformed into a table similar to the Output Table, where each row represents one subject.
Input Table:
| ExperimentName | Subject | Trial | Score1 | Score2 | Score3 | Score4 | ... | ScoreN |