on-internet
← Community

How can extract data from .h5 file and save it in .txt or .csv properly?

Stack Overflow ·

After searching a lot I couldn't find a simple way to extract data from .h5 and pass it to a data.Frame by Numpy or Pandas in order to save in .txt or .csv file. import h5py import numpy as np import pandas as pd filename = 'D:\data.h5' f = h5py.File(filename, 'r') # List all groups print("Keys: %s" % f.keys()) a_group_key = list(f.keys())[0] # Get the data data = list(f[a_group_key]) pd.DataFrame(data).to_csv("hi.csv") Keys: <KeysViewHDF5 ['dd48']> When I print data I see following results: print(data) ['axis0', 'axis1', 'block0_items', 'block0_values', 'block1_items', 'block1_values'] I woul

Comments

Sign in or sign up to comment and upvote.

No comments yet.