gonum / hdf5

hdf5 is a wrapper for the HDF5 library
BSD 3-Clause "New" or "Revised" License
131 stars 33 forks source link

[Help wanted] How do I follow a link? #69

Closed doctordesh closed 4 years ago

doctordesh commented 4 years ago

Hey!

I'm using the lib to look at a HDF5 file that is a master file, which references other files. I come as far as stating that a link for a certain sub-file exists, but the path to that file is in something called Link Target Info. How do I extract that from the link?

package main

import (
    "fmt"

    "gonum.org/v1/hdf5"
)

func main() {
    hdf5.DisplayErrors(true)

    // open the file and the dataset
    f, err := hdf5.OpenFile("data/master.h5", hdf5.F_ACC_RDONLY)
    if err != nil {
        panic("err 1 - " + err.Error())
    }
    defer f.Close()

    g1, err := f.OpenGroup("entry")
    if err != nil {
        panic("err 2 - " + err.Error())
    }
    defer g1.Close()

    g2, err := g1.OpenGroup("data")
    if err != nil {
        panic("err 3 - " + err.Error())
    }
    defer g2.Close()

    num, err := g2.NumObjects()
    if err != nil {
        panic("err 4 - " + err.Error())
    }

    for i := uint(0); i < num; i++ {
        name, err := g2.ObjectNameByIndex(i)
        if err != nil {
            panic("err 5 - " + err.Error())
        }

        b := g2.LinkExists(name)
        fmt.Printf("Link for %s exists? %v\n", name, b)
    }
}
kortschak commented 4 years ago

The issue tracker is not really the right place for asking questions. You'll get better responses by posting to gonum-dev as noted in the issue template.

doctordesh commented 4 years ago

Thanks for being polite, even though the fault is mine. I should have read the template more carefully. Closing