How can I create a Hdf5 dataset file from several h5 files?

13 ビュー (過去 30 日間)
Gulfam Saju
Gulfam Saju 2022 年 4 月 7 日
回答済み: Ayush Modi 2024 年 1 月 1 日
I want to create a Hdf5 dataset by compressing more than hundred h5 files. How can I do that?
  2 件のコメント
per isakson
per isakson 2022 年 4 月 8 日
編集済み: per isakson 2022 年 4 月 8 日
I'm not sure I understand the meaning of "Hdf5 dataset".
Gulfam Saju
Gulfam Saju 2022 年 4 月 8 日
I mean, I want to create a dataset, where the format is hdf5 by compressing several h5 files.

サインインしてコメントする。

回答 (1 件)

Ayush Modi
Ayush Modi 2024 年 1 月 1 日
Hi Gulfam,
As per my understanding, you want to merge multiple h5 files into a single hdf5 file and apply a compression on the hdf5 file. You can achieve this using the functions “h5read”, “h5create” and “h5write”. Here is an example to demonstrate how you can accomplish this:
% List of .h5 files to be combined
h5_files = {'sample1.h5', 'sample2.h5'}; % Add your file names here
% Name of the new combined HDF5 file
combined_hdf5_file = 'combined_data3.hdf5';
% Dataset name within the .h5 files that you want to combine
dataset_name = '/myDataset1';
% Initialize a variable to hold all the data
all_data = [];
% Loop through each .h5 file
for i = 1:length(h5_files)
% Read the dataset from the .h5 file
data = h5read(h5_files{i}, dataset_name);
% Concatenate the data
all_data = cat(1, all_data, data); % Adjust the dimension as necessary
end
% Create the new .hdf5 file and write the combined dataset
h5create(combined_hdf5_file, dataset_name, size(all_data), 'ChunkSize',[size(all_data)], 'Deflate',9);
h5write(combined_hdf5_file, dataset_name, all_data);
Please refer to the following MathWorks documentation for more information on “h5create” function:
I hope this resolves the issue you were facing.

カテゴリ

Help Center および File ExchangeHDF5 についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by