Need to turn x:
X = [['A', 'B', 'C'], ['A', 'B', 'D']]
Into Y:
Y = {'A': {'B': {'C','D'}}}
More specifically, I need to create a tree of folders and files from a list of absolute paths, which looks like this:
paths = ['xyz/123/file.txt', 'abc/456/otherfile.txt']
where, each path is split("/")
, as per ['A', 'B', 'C']
in the pseudo example.
As this represents files and folders, obviously, on the same level (index of the array) same name strings can't repeat.
{'C','D'}
{'A': {'B': {'C': {}, 'D': {}}}}