HDF5.jl icon indicating copy to clipboard operation
HDF5.jl copied to clipboard

Request for improved documentation: Array of String

Open StefanPofahl opened this issue 3 years ago • 8 comments

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

StefanPofahl avatar May 06 '22 14:05 StefanPofahl

Upstream documentation is here: https://portal.hdfgroup.org/display/HDF5/Datatypes#Datatypes-varlendt

mkitti avatar May 13 '22 01:05 mkitti

See also https://github.com/JuliaIO/HDF5.jl/blob/master/test/plain.jl#L64

musm avatar May 13 '22 01:05 musm

@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.

musm avatar May 18 '22 17:05 musm

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. image

mkitti avatar May 18 '22 17:05 mkitti

True, the interface is also rather low-level, so that could be a point of further improvement.

musm avatar May 18 '22 18:05 musm

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 avatar May 19 '22 14:05 StefanPofahl

@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"

bjarthur avatar Jun 16 '23 21:06 bjarthur

Thanks! :-)

StefanPofahl avatar Jun 16 '23 23:06 StefanPofahl