I ended up into a problem.
Let's say i have a given array, or 4 separate lists( the columns )
P1 L1 V1 O1
P1 L1 V1 O2
P1 L1 V2 O1
P1 L1 V3 O3
P2 L1 V2 O1
P2 L2 V1 O2
P2 L3 V4 O2
I would like to transform this into a python tree structure:
P1|
|L1|
|V1|
| |O1
| |O2
| |O3
|V2|
| |O1
|V3|
|O3
P2|
|L1|V2|O1
|L2|V1|O2
|L3|V4|O2
Ok now, this given array can change depending on the user input, it will always have this "kind of structure", but it's not defined a priori.
My goal is to define such a structure and have the possibility to know all the parents of a given children at the lowest level.
To sum up, as suggested from @trincot I enter an input/output data type:
Input: 4 lists, example:
['P1', 'P1', 'P1', 'P1', 'P1', 'P1', 'P1', 'P1', 'P1', 'P1', 'P1', 'P1', 'P2', 'P2', 'P2', 'P2', 'P2', 'P2', 'P2', 'P2', 'P2', 'P2']
output: One tree structure like this:
{'P1': {'L1': {'V1': {'O1': 'O1'}}, 'L2': {'V2': {'O2': 'O2'}, 'V1': {'O1': 'O1'}}}, 'P2': {'L1': {'V1': {'O1': 'O1'}}, 'L2': {'V2': {'O2': 'O2'}, 'V1': {'O1': 'O1'}}}}
In the output I would like then to know at last level what are the elements and know all the parents of this element.
Of course if another data type is more appropriate I would appreciate any suggestion.
Thanks for your help!