Skip to content

Commit 2df27a1

Browse files
committed
add sample Worksheet User Tree Access.py
1 parent 756904d commit 2df27a1

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
'''
2+
This sample shows how to set values to worksheet tree nodes, and
3+
then read out into a tree object. This is useful to save the metadata
4+
of a data file. See the blog:
5+
https://blog.originlab.com/accessing-metadata-using-python
6+
'''
7+
8+
import originpro as op
9+
10+
# Create a new worksheet and set worksheet tree values.
11+
wks = op.new_sheet()
12+
wks.set_str("tree.data.name", "Larry")
13+
wks.set_int("tree.data.age", 37)
14+
wks.set_float("tree.data.mean", 23.56)
15+
16+
# Save the worksheet tree values to a tree object and print out the values.
17+
trWks = wks.usertree
18+
trData = trWks.find('data')
19+
for child in trData:
20+
print(f'{child.tag} = {child.text}')

0 commit comments

Comments
 (0)