Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support reading strings? #1

Open
maximsch2 opened this issue Jul 14, 2017 · 4 comments
Open

Support reading strings? #1

maximsch2 opened this issue Jul 14, 2017 · 4 comments

Comments

@maximsch2
Copy link

It would be great if this library would support reading arrays of strings from HDF5 files.

@sabhiram
Copy link

Could you propose a sample usage?

@maximsch2
Copy link
Author

I'm not sure what you mean. I ocasionally use HDF5 as a cross-language storage format (with the advantage of being able to memory-map it) and would like to be able to store and load arrays of strings among other things. I think the original request was related to storing descriptions of the samples stored in another HDF5 collection.

@jpfairbanks
Copy link

I am using HDF5 to interoperate with some matlab code and need to store and load strings in HDF5 files.

package main
import ("fmt"
            "github.com/ready-steady/hdf5")
func main() {
	fp, _ := hdf5.Create("strings.hdf5")
	defer fp.Close()
	fp.Put("key", []string{"Hello", "HDF5"})
	st := &[]string{}
	fp.Get("key", st)
	fmt.Printf("The String Array is: %v\n", st)
}

Which gives an error message

  #000: H5D.c line 294 in H5Dopen2(): unable to open dataset
    major: Dataset
    minor: Can't open object
  #001: H5Dint.c line 1362 in H5D__open_name(): not found
    major: Dataset
    minor: Object not found
  #002: H5Gloc.c line 428 in H5G_loc_find(): can't find object
    major: Symbol table
    minor: Object not found
  #003: H5Gtraverse.c line 867 in H5G_traverse(): internal path traversal failed
    major: Symbol table
    minor: Object not found
  #004: H5Gtraverse.c line 639 in H5G_traverse_real(): traversal operator failed
    major: Symbol table
    minor: Callback failed
  #005: H5Gloc.c line 383 in H5G_loc_find_cb(): object 'key' doesn't exist
    major: Symbol table
    minor: Object not found
The String Array is: &[]

@jpfairbanks
Copy link

Note that if you want to store a single string, you can use []byte(str) to store your string as an array of bytes, which might work for some use cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

4 participants