Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def treeify(lst):
- tree = [copy.deepcopy(cat) for cat in lst if cat['CategoryLevel'] == '1']
- for el in tree:
- el["children"] = []
- for i in xrange(len(lst)):
- for j in xrange(len(tree)):
- if lst[i]["CategoryParentID"] == tree[j]["CategoryID"]:
- tree[j]["children"].append(copy.deepcopy(lst[i]))
- return tree
- tree = treeify(http://pastebin.com/RL1jGGyR)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement