![]() |
HDF5
1.14.5-1
APIReference
|
Navigate back: Main / Getting Started with HDF5 / Command-line Tools
The h5dump utility can be used to convert an HDF5 dataset into an ASCII file, which can then be imported into Excel and other applications. The following options are used:
| Options | Description |
|---|---|
| -d D, –dataset=D | Display dataset D |
| -o F, –output=F | Output raw data into file F |
| -y, –noindex | Suppress printing of array indices with the data |
| -w N, –width=N | Set N number of columns of output. A value of 0 sets the number to 65535 (the maximum) |
As an example, h5_crtdat.c from the Creating a Dataset HDF5 Tutorial topic, creates the file dset.h5 with a dataset /dset that is a 4 x 6 integer array. The following is displayed when viewing dset.h5 with h5dump:
The following command will output the values of the /dset dataset to the ASCII file dset.asci:
In particular, note that:
h5dump is to print indices, and the -y option suppresses this. -w 50 option tells h5dump to allow 50 columns for outputting the data. The value specified must be large enough to accommodate the dimension size of the dataset multiplied by the number of positions and spaces needed to print each value. If the value is not large enough, the output will wrap to the next line, and the data will not display as expected in Excel or other applications. To ensure that the output does not wrap to the next line, you can also specify 0 (zero) for the -w option.In addition to creating the ASCII file dset.asci, the above command outputs the metadata of the specified dataset:
The dset.asci file will contain the values for the dataset:
The h5dump utility can be used to convert an HDF5 dataset to a binary file with the following options:
| Options | Description |
|---|---|
| -d D, –dataset=D | Display dataset D |
| -o F, –output=F | Output raw data into file F |
| -b B, –binary=B | Binary file output of form B. Valid values are: LE, BE, NATIVE, FILE |
As an example, h5_crtdat.c from the Creating a Dataset HDF5 Tutorial topic, creates the file dset.h5 with a dataset /dset that is a 4 x 6 integer array. The following is displayed when viewing dset.h5 with h5dump:
As specified by the -d and -o options, the following h5dump command will output the values of the dataset /dset to a file called dset.bin. The -b option specifies that the output will be binary in Little Endian format (LE).
This command outputs the metadata for the dataset, as well as creating the binary file dset.bin:
If you look at the resulting dset.bin file with a binary editor, you will see that it contains the dataset's values. For example (on Linux) you will see:
The h5import utility can use the output of h5dump as input to create a dataset or file.
The h5dump utility must first create two files:
h5import configuration file The DDL file must be generated with the h5dump -p option, to generate properties.
The raw data file that can be imported into HDF5 using this method may contain either numeric or string data with the following restrictions:
h5dump -b option to produce a binary data file. h5dump -y and –width=1 options, generating a single column of strings without indices.Two examples follow: the first imports a dataset with a numeric datatype. Note that numeric data requires the use of the h5dump -b option to produce a binary data file. The example program (h5_crtdat.c) that creates this file is included with the Introduction to HDF5 tutorial and can be obtained from the Examples from Learning the Basics page:
The output before and after running these commands is shown below:
The second example imports string data. The example program that creates this file can be downloaded from the Examples by API page.
Note that string data requires use of the h5dump -y option to exclude indexes and the h5dump –width=1 option to generate a single column of strings. The -o option outputs the data into an ASCII file.
The output before and after running these commands is shown below:
Navigate back: Main / Getting Started with HDF5 / Command-line Tools