Hi,
I have a dataset "dataset_label" in a hdf5 file format which contains a
string of N elements equals to "None\0". I read the dataset using hdf5 C++
API:
hid_t datatype = H5Tcopy (H5T_C_S1);
H5Tset_size (datatype, H5T_VARIABLE);
H5::DataType dtype = dataset_label.getDataType();
dataset_label.read(h5_data->label ,dtype ,memspace_l, dataspace_l);
I then replace "None\0" with a variable length strings(ranging from 3-35
chars in each end with null terminator) in char* Label_buf and want to
over-write these new strings in the dataset, but when I use the c++ example
varlen.cpp :
H5::StrType tid1(0, H5T_VARIABLE);
dataset_label.write((void*)Label_buf,tid1);
I get a run-time error as follows:
HDF5-DIAG: Error detected in HDF5 (1.8.6) thread 0:
#000: H5Dio.c line 266 in H5Dwrite(): can't write data
major: Dataset
minor: Write failed
#001: H5Dio.c line 541 in H5D_write(): unable to set up type info
major: Dataset
minor: Unable to initialize object
#002: H5Dio.c line 836 in H5D_typeinfo_init(): unable to convert between
src and dest datatype
major: Dataset
minor: Feature is unsupported
#003: H5T.c line 4449 in H5T_path_find(): no appropriate function for
conversion path
major: Datatype
minor: Unable to initialize object
if I do
H5::DataType dtype = dataset_label.getDataType();
dataset_label.read(h5_data->label ,dtype ,memspace_l, dataspace_l);
it doesn't throw an error but the written string in the dataset is totally
messed-up.
Can anyone please tell me what is the write way to over-write my
variable-length strings or any alternative?
Thank you so much in advance
Sahar
···
--
View this message in context: http://hdf-forum.184993.n3.nabble.com/over-writing-variable-length-string-in-dataset-using-hdf5-C-API-tp3219658p3219658.html
Sent from the hdf-forum mailing list archive at Nabble.com.
Hi,
I've looked at the example and in my code h5_data->label is of type char* (h5_data is a struct). I'm assuming that the problem is in the data type conversion from python to C++? I have created the dataset containing "None\0" strings in python and I read it in C++ , substitute the strings and want to save them back to the dataset.
Thank you
Sahar
···
From: Quincey Koziol [via hdf-forum] <ml-node+3259705-1024731068-381125@n3.nabble.com>
Sent: Tue, 8/16/2011 3:53pm
To: sghanavati <sahar.ghanavati@phenogenomics.ca>
Subject: Re: over-writing variable length string in dataset using hdf5 C++ API
Hi Sahar,
On Aug 2, 2011, at 12:41 PM, sghanavati wrote:
Hi,
I have a dataset "dataset_label" in a hdf5 file format which contains a
string of N elements equals to "None\0". I read the dataset using hdf5 C++
API:
hid_t datatype = H5Tcopy (H5T_C_S1);
H5Tset_size (datatype, H5T_VARIABLE);
H5::DataType dtype = dataset_label.getDataType();
dataset_label.read(h5_data->label ,dtype ,memspace_l, dataspace_l);
I then replace "None\0" with a variable length strings(ranging from 3-35
chars in each end with null terminator) in char* Label_buf and want to
over-write these new strings in the dataset, but when I use the c++ example
varlen.cpp :
H5::StrType tid1(0, H5T_VARIABLE);
dataset_label.write((void*)Label_buf,tid1);
I get a run-time error as follows:
HDF5-DIAG: Error detected in HDF5 (1.8.6) thread 0:
#000: H5Dio.c line 266 in H5Dwrite(): can't write data
major: Dataset
minor: Write failed
#001: H5Dio.c line 541 in H5D_write(): unable to set up type info
major: Dataset
minor: Unable to initialize object
#002: H5Dio.c line 836 in H5D_typeinfo_init(): unable to convert between
src and dest datatype
major: Dataset
minor: Feature is unsupported
#003: H5T.c line 4449 in H5T_path_find(): no appropriate function for
conversion path
major: Datatype
minor: Unable to initialize object
if I do
H5::DataType dtype = dataset_label.getDataType();
dataset_label.read(h5_data->label ,dtype ,memspace_l, dataspace_l);
it doesn't throw an error but the written string in the dataset is totally
messed-up.
Can anyone please tell me what is the write way to over-write my
variable-length strings or any alternative?
Thank you so much in advance
When you write a variable-length string, you need to pass a pointer to the 'char *' for the write operation. Take a look at the testing code in test/tvlstr.c for examples of this in C.
Quincey
_______________________________________________
Hdf-forum is for HDF software users discussion.
[hidden email]
http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org
If you reply to this email, your message will be added to the discussion below:
http://hdf-forum.184993.n3.nabble.com/over-writing-variable-length-string-in-dataset-using-hdf5-C-API-tp3219658p3259705.html
To unsubscribe from over-writing variable length string in dataset using hdf5 C++ API, click here.
--
View this message in context: http://hdf-forum.184993.n3.nabble.com/over-writing-variable-length-string-in-dataset-using-hdf5-C-API-tp3219658p3259968.html
Sent from the hdf-forum mailing list archive at Nabble.com.
Hi Sahar,
Hi,
I've looked at the example and in my code h5_data->label is of type char* (h5_data is a struct). I'm assuming that the problem is in the data type conversion from python to C++? I have created the dataset containing "None\0" strings in python and I read it in C++ , substitute the strings and want to save them back to the dataset.
I'm not familiar enough with Python to answer your question, sorry. Anyone else?
Quincey
···
On Aug 16, 2011, at 5:00 PM, sghanavati wrote:
Thank you
Sahar
From: Quincey Koziol [via hdf-forum] <[hidden email]>
Sent: Tue, 8/16/2011 3:53pm
To: sghanavati <[hidden email]>
Subject: Re: over-writing variable length string in dataset using hdf5 C++ API
Hi Sahar,
On Aug 2, 2011, at 12:41 PM, sghanavati wrote:
> Hi,
>
> I have a dataset "dataset_label" in a hdf5 file format which contains a
> string of N elements equals to "None\0". I read the dataset using hdf5 C++
> API:
>
> hid_t datatype = H5Tcopy (H5T_C_S1);
> H5Tset_size (datatype, H5T_VARIABLE);
> H5::DataType dtype = dataset_label.getDataType();
> dataset_label.read(h5_data->label ,dtype ,memspace_l, dataspace_l);
>
> I then replace "None\0" with a variable length strings(ranging from 3-35
> chars in each end with null terminator) in char* Label_buf and want to
> over-write these new strings in the dataset, but when I use the c++ example
> varlen.cpp :
>
> H5::StrType tid1(0, H5T_VARIABLE);
> dataset_label.write((void*)Label_buf,tid1);
>
> I get a run-time error as follows:
> HDF5-DIAG: Error detected in HDF5 (1.8.6) thread 0:
> #000: H5Dio.c line 266 in H5Dwrite(): can't write data
> major: Dataset
> minor: Write failed
> #001: H5Dio.c line 541 in H5D_write(): unable to set up type info
> major: Dataset
> minor: Unable to initialize object
> #002: H5Dio.c line 836 in H5D_typeinfo_init(): unable to convert between
> src and dest datatype
> major: Dataset
> minor: Feature is unsupported
> #003: H5T.c line 4449 in H5T_path_find(): no appropriate function for
> conversion path
> major: Datatype
> minor: Unable to initialize object
>
>
> if I do
> H5::DataType dtype = dataset_label.getDataType();
> dataset_label.read(h5_data->label ,dtype ,memspace_l, dataspace_l);
>
> it doesn't throw an error but the written string in the dataset is totally
> messed-up.
> Can anyone please tell me what is the write way to over-write my
> variable-length strings or any alternative?
> Thank you so much in advance
When you write a variable-length string, you need to pass a pointer to the 'char *' for the write operation. Take a look at the testing code in test/tvlstr.c for examples of this in C.
Quincey
_______________________________________________
Hdf-forum is for HDF software users discussion.
[hidden email]
http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org
If you reply to this email, your message will be added to the discussion below:
http://hdf-forum.184993.n3.nabble.com/over-writing-variable-length-string-in-dataset-using-hdf5-C-API-tp3219658p3259705.html
To unsubscribe from over-writing variable length string in dataset using hdf5 C++ API, click here.
View this message in context: RE: over-writing variable length string in dataset using hdf5 C++ API
Sent from the hdf-forum mailing list archive at Nabble.com.
_______________________________________________
Hdf-forum is for HDF software users discussion.
Hdf-forum@hdfgroup.org
http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org