I am trying to build a Hierarchy from the below csv data:
Child,Parent,IsActive
11074165,11018432,NO
11094122,11033371,NO
11020499,11018277,NO
11018432,11020499,NO
Below is the code snippet
Child,Parent,IsActive
11074165,11018432,NO
11094122,11033371,NO
11020499,11018277,NO
11018432,11020499,NO
Below is the code snippet
nodes = {} with open("SampleHierarchy.csv", "r") as f: csv_reader = csv.DictReader(f) for row in csv_reader: #print(row['Code'], row['Parent'],row['IsActive']) childItem=row['Code'] parentItem=row['Parent'] nodes[childItem] = Node(childItem, parent=parentItem)But getting the Error:
Error:*Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 880, in runfile
execfile(filename, namespace)
File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "CounterpartyHierarchyTree.py", line 37, in <module>
Node(childItem, parent=parentItem)
File "C:\ProgramData\Anaconda3\lib\site-packages\anytree\node\node.py", line 77, in __init__
self.parent = parent
File "C:\ProgramData\Anaconda3\lib\site-packages\anytree\node\nodemixin.py", line 127, in parent
raise TreeError(msg)
anytree.node.exceptions.TreeError: Parent node '11018432' is not of type 'NodeMixin'.*
Larz60+ write May-05-2022, 10:36 AM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Fixed for you this time. Please use BBCode tags on future posts.
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Fixed for you this time. Please use BBCode tags on future posts.