Writing strings to a dataset #34
Unanswered
JonesRusty
asked this question in
Q&A
Replies: 1 comment 1 reply
-
|
This writes a fixed unicode string of length 20: use hdf5_metno as hdf5;
use hdf5_metno::H5Type;
use std::str::FromStr;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let file = hdf5::File::create("file.h5")?;
type T = hdf5::types::FixedUnicode::<20>;
let data = T::from_str("This string")?;
let ds = file.new_dataset::<T>().create("string")?;
ds.write_scalar(&data)?;
Ok(())
} |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am new to Rust but have used HDF5 previously (in C++).
I am trying to figure out how to write a dataset that contains a single (fixed-length) string.
I can't find any examples and cannot see how to do this.
Beta Was this translation helpful? Give feedback.
All reactions