Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert HDF5 file to other formats

Tags:

python

hdf5

h5py

I am having a few big files sets of HDF5 files and I am looking for an efficient way of converting the data in these files into XML, TXT or some other easily readable format. I tried working with the Python package (www.h5py.org), but I was not able to figure out any methods with which I can get this stuff done fast enough. I am not restricted to Python and can also code in Java, Scala or Matlab. Can someone give me some suggestions on how to proceed with this?

Thanks,

TM

like image 933
visakh Avatar asked Apr 23 '14 07:04

visakh


People also ask

How do I open a HDF5 file?

Open a HDF5/H5 file in HDFView To begin, open the HDFView application. Within the HDFView application, select File --> Open and navigate to the folder where you saved the NEONDSTowerTemperatureData. hdf5 file on your computer. Open this file in HDFView.

How do I convert a HDF file to Excel?

Excel cannot import HDF-EOS data directly. Thus, you need to generate ASCII values or create CSV file that can Excel read. Or, you need to import data through ODBC or Excel add-in.

Is HDF5 a binary format?

The HDF5 file format is a cross platform binary format for storing scientific data. HDF5 allows you to reduce the size of the file data by compressing repeated values. This allows your data to be read and written much faster than if you stored the data as ASCII (plain text) files.


2 Answers

Mathias711's method is the best direct way. If you want to do it within python, then use pandas.HDFStore:

from pandas import HDFStore

store = HDFStore('inputFile.hd5')

store['table1Name'].to_csv('outputFileForTable1.csv')
like image 95
Ramón J Romero y Vigil Avatar answered Oct 12 '22 13:10

Ramón J Romero y Vigil


You can use h5dump -o dset.asci -y -w 400 dset.h5

  • -o dset.asci specifies the output file
  • -y -w 400 specifies the dimension size multiplied by the number of positions and spaces needed to print each value. You should take a very large number here.
  • dset.h5 is of course the hdf5 file you want to convert

I think this is the easiest way to convert it to an ascii file, which you can import to excel or whatever you want. I did it a couple of times, and it worked for me. I got his information from this website.

like image 5
Mathias711 Avatar answered Oct 12 '22 14:10

Mathias711