I would like to transform the following list:
data = {{0, A1, 1}, {1, C1, 2}, {1, C2, 3}, {3, C4, 1}, {0, A2, 1}, {1, C2, 1},
{0, A1, 4}, {1, C1, 1}, {2, C2, 1}}
into another list like this:
output = {{A1, 1, 0, A1, 1}, {A1, 1, 1, C1, 2}, {A1, 1, 1, C2, 3}, {A1, 1, 3, C4, 1},
{A2, 1, 0, A2, 1}, {A2, 1, 1, C2, 1}, {A1, 4, 0, A1, 4}, {A1, 4, 1, C1, 1},
{A1, 4, 2, C2, 1}}
Basically, the first column indicates the level, 0 being the head level of a bill of material and would like to put the header item and header quantity as columns besides the components for easier computation further along.
Thanks.