summaryrefslogtreecommitdiffstats
path: root/examples/save_tree_2_file.py
diff options
context:
space:
mode:
Diffstat (limited to 'examples/save_tree_2_file.py')
-rw-r--r--examples/save_tree_2_file.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/examples/save_tree_2_file.py b/examples/save_tree_2_file.py
new file mode 100644
index 0000000..3b564f5
--- /dev/null
+++ b/examples/save_tree_2_file.py
@@ -0,0 +1,12 @@
+# -*- coding: utf-8 -*-
+
+from treelib import Tree
+
+tree = Tree()
+tree.create_node("Harry", "harry") # root node
+tree.create_node("Jane", "jane", parent="harry")
+tree.create_node("Bill", "bill", parent="harry")
+tree.create_node("Diane", "diane", parent="jane")
+tree.create_node("Mary", "mary", parent="diane")
+tree.create_node("Mark", "mark", parent="jane")
+tree.save2file("tree.txt")