Advanced file navigation and object hierarchy exploration
- Detailed object traversal
- Reading group children
- Exploring nested structures
- Understanding object relationships
go run main.goOutput:
Superblock version: 2
Objects in file:
Group: / (children: 1)
- data
Dataset: /data
case *hdf5.Group:
fmt.Printf(" Group: %s (children: %d)\n",
path, len(v.Children()))
// List all children
for _, child := range v.Children() {
fmt.Printf(" - %s\n", child.Name())
}case *hdf5.Dataset:
fmt.Printf(" Dataset: %s\n", path)var groups, datasets int
file.Walk(func(path string, obj hdf5.Object) {
switch obj.(type) {
case *hdf5.Group:
groups++
case *hdf5.Dataset:
datasets++
}
})
fmt.Printf("Groups: %d, Datasets: %d\n", groups, datasets)index := make(map[string]hdf5.Object)
file.Walk(func(path string, obj hdf5.Object) {
index[path] = obj
})
// Later: access any object by path
if obj, ok := index["/data"]; ok {
fmt.Printf("Found: %s\n", obj.Name())
}file.Walk(func(path string, obj hdf5.Object) {
depth := strings.Count(path, "/") - 1
if depth > 3 {
fmt.Printf("Deep object: %s (depth: %d)\n",
path, depth)
}
})- Example 03 - Read dataset values
- Reading Data Guide - Complete guide
Part of the HDF5 Go Library v0.10.0-beta