HDF5.jl
HDF5.jl copied to clipboard
Request for improved documentation: Array of String
Hi,
I am lost with the following peace of information in the documentation: "Arrays of strings are supported using HDF5's variable-length-strings facility."
What does it means in pratical terms?
Let's assume is have:
info_ChannelNames = String[]
push!(info_ChannelNames,
"sample_array_A",
"sample_array_B"
)
How would I write this to the HDF5-container?
Regards,
Stefan
Upstream documentation is here: https://portal.hdfgroup.org/display/HDF5/Datatypes#Datatypes-varlendt
See also https://github.com/JuliaIO/HDF5.jl/blob/master/test/plain.jl#L64
@StefanPofahl does that solve your issue? If so please feel free to close this issue. Also if you found any part of the documentation lacking on this, feel free to open a PR with additional clarification.
I think we could document this better here: https://github.com/JuliaIO/HDF5.jl/blob/master/docs/src/index.md#reading-and-writing-data
Click the pencil icon to start.

True, the interface is also rather low-level, so that could be a point of further improvement.
Sorry for my late reply, thanks for the explanation! For the moment I misused the key of a group/struct to build an array of strings.
P.S.: What is the most powerful approach to shrink the files size? Background we record data with sampling rates above 100kS/s. The original data is stored in a proprietary format and after export to HDF5 the file size increases.
Am Mi., 18. Mai 2022 um 20:42 Uhr schrieb Mustafa M < @.***>:
True, the interface is also rather low-level, so that could be a point of further improvement.
— Reply to this email directly, view it on GitHub https://github.com/JuliaIO/HDF5.jl/issues/931#issuecomment-1130380097, or unsubscribe https://github.com/notifications/unsubscribe-auth/APREBE37GQEOEBJUUZZK7ITVKU2Y3ANCNFSM5VIIPJMQ . You are receiving this because you were mentioned.Message ID: @.***>
@StefanPofahl like this:
julia> using HDF5
julia> info_ChannelNames = String[]
String[]
julia> push!(info_ChannelNames,
"sample_array_A",
"sample_array_B"
)
2-element Vector{String}:
"sample_array_A"
"sample_array_B"
julia> fid = h5open("foo.h5", "w")
🗂️ HDF5.File: (read-write) foo.h5
julia> write(fid, "ChannelNames", info_ChannelNames)
julia> close(fid)
julia> fid = h5open("foo.h5", "r")
🗂️ HDF5.File: (read-only) foo.h5
└─ 🔢 ChannelNames
julia> read(fid, "ChannelNames")
2-element Vector{String}:
"sample_array_A"
"sample_array_B"
Thanks! :-)