In [1]:
import zarr
zarr.__version__
Out[1]:
'2.3.3.dev87'
In [2]:
g1 = zarr.group()
g2 = g1.create_group('foo')
g3 = g1.create_group('bar')
g3.create_group('baz')
g3.create_dataset('xxx', shape=100)
g3.create_dataset('yyy', shape=(100, 100), dtype='i4')
g5 = g3.create_group('quux')
g5.create_dataset('aaa', shape=100)
g5.create_dataset('bbb', shape=(100, 100), dtype='i4')
g7 = g3.create_group('zoo')

Generate text (unicode) tree:

In [3]:
print(g1.tree())
/
 ├── bar
 │   ├── baz
 │   ├── quux
 │   │   ├── aaa (100,) float64
 │   │   └── bbb (100, 100) int32
 │   ├── xxx (100,) float64
 │   ├── yyy (100, 100) int32
 │   └── zoo
 └── foo

The level parameter controls how deep the tree is.

In [4]:
print(g1.tree(level=1))
/
 ├── bar
 └── foo
In [5]:
print(g1.tree(level=2))
/
 ├── bar
 │   ├── baz
 │   ├── quux
 │   ├── xxx (100,) float64
 │   ├── yyy (100, 100) int32
 │   └── zoo
 └── foo

Alternative plain ASCII tree:

In [6]:
print(bytes(g1.tree()).decode())
/
 +-- bar
 |   +-- baz
 |   +-- quux
 |   |   +-- aaa (100,) float64
 |   |   +-- bbb (100, 100) int32
 |   +-- xxx (100,) float64
 |   +-- yyy (100, 100) int32
 |   +-- zoo
 +-- foo

HTML trees:

In [7]:
g1.tree()

Use expand=True to have all groups automatically expanded.

In [8]:
g1.tree(expand=True)
In [9]:
g1.tree(expand=True, level=2)
In [10]:
g1.tree(expand=True, level=1)

The expand parameter can also be an integer, giving the depth to expand to.

In [11]:
g1.tree(expand=1)
In [12]:
g1.tree(expand=2)
In [13]:
g1.tree(expand=3)
In [ ]: