Convert HDF5 to CSV
How to convert HDF5 (.h5 / .hdf5) datasets to CSV — find the dataset in your browser, then export it free
MATLAB .mat files saved with -v7.3 are HDF5 in disguise — the MAT guide covers that case. For formats we convert instantly in the browser, see all of our CSV converters.
HDF5 (.h5 or .hdf5 — same format, different extension) isn’t a table, it’s a container: datasets organized into groups, like folders within a single file. That means “convert to CSV” really means “pick a dataset and export it” — one HDF5 file can yield several CSVs. There’s no in-browser converter for this format here yet; the free two-step route below works for any HDF5 file. Python users can jump straight to that section.
No installation: find the dataset, then export it
Step 1: Find your dataset path with myHDF5
Go to myhdf5.hdfgroup.org — the HDF Group’s free in-browser viewer. It runs entirely client-side (your file is never uploaded), so it’s safe even for confidential data. Open your file, browse the tree, and note the path of the dataset you want, e.g. results/temperature.
Step 2: Export it with Google Colab
- Open Colab — Go to colab.research.google.com, sign in with any Google account, and click New Notebook.
- Upload your file — Click the folder icon in the left sidebar, then the upload button, and select your
.h5file. - Run the code — Paste the snippet below into the cell and press the run button.
- Download the result — Refresh the file sidebar, right-click
output.csv, and choose Download.
import h5py
import pandas as pd
with h5py.File("yourfile.h5", "r") as f:
f.visit(print) # lists every dataset path — handy if you skipped step 1
data = f["results/temperature"][()] # replace with your dataset path
pd.DataFrame(data).to_csv("output.csv", index=False)
Unlike myHDF5, Colab does put the file on Google’s servers (in a temporary private session that disappears when the tab closes) — for confidential data use HDFView below instead.
Free desktop app: HDFView
HDFView is the HDF Group’s official free desktop browser (Windows/macOS/Linux, from hdfgroup.org). Open the file, double-click a dataset to view it as a table, then use Table → Export Data to Text File. Note the output is a delimited text file rather than a ready-made .csv — fine for a quick look, but the Colab route gives you a cleaner CSV.
Python
Two cases, and mixing them up is the usual failure:
- The file was written by pandas (
df.to_hdf(...)): read it back withpandas.read_hdf(). - Any other HDF5 file (instruments, simulations, other languages):
read_hdfwill fail — use h5py, list the dataset paths, and pick one.
import pandas as pd
df = pd.read_hdf("data.h5") # pandas-written files only
df.to_csv("output.csv", index=False)
For generic files, use the h5py snippet from the Colab section — it’s identical locally (pip install h5py pandas first).
R
rhdf5 exists on Bioconductor, but unless you’re already in that ecosystem the install friction isn’t worth it — use the Colab route instead.
Which method should I use?
| Your situation | Best method |
|---|---|
| No software installed, one file, data not confidential | myHDF5 + Google Colab |
| Confidential data that can’t leave your computer | myHDF5 (view) + HDFView (export) |
| Many files or datasets, or a task you’ll repeat | Python with h5py |