HDF5, how to save string data to file?

57 views
Skip to first unread message

program...@gmail.com

unread,
Oct 13, 2016, 6:36:06 AM10/13/16
to julia-users
how to save string data to file? What wrong ?

julia> dset = d_create(g, "/dane", datatype(String), dataspace(nol))
ERROR: `datatype` has no method matching datatype(::Type{String})

julia> dset = d_create(g, "/dane", datatype(UTF8String), dataspace(nol))
ERROR: `datatype` has no method matching datatype(::Type{UTF8String})

julia> dset = d_create(g, "/dane", datatype(ASCIIString), dataspace(nol))
ERROR: `datatype` has no method matching datatype(::Type{ASCIIString})

Paul

Erik Schnetter

unread,
Oct 13, 2016, 10:31:56 AM10/13/16
to julia...@googlegroups.com
You could look at the JLD package instead of using HDF5 directly.

The HDF5 package might be missing support for variable-length strings.

-erik

Steven G. Johnson

unread,
Oct 13, 2016, 12:56:48 PM10/13/16
to julia-users
HDF5.jl supports writing strings.   

For some reason, datatype(String) doesn't work, but datatype("This is a string") works.  So just pass the string data, and not the string type, to datatype.

Even simpler, just do write(g, "/dane", "my string"), for example.


Reply all
Reply to author
Forward
0 new messages