DEV Community


Day 67 Of 100DaysOfCode: Extracting Data From HDF5 File

iamdurga profile image Durga Pokharel ・2 min read

Today is my 67th day of #100daysofcode and #python learning. Today I learned introduction to importing data in python. Gain knowledge of importing different data file like flat file, csv file, file from other software, relational database, excel spreadsheets, MATLAB files, SAS file, stata file, HDF5 file, pickled file. Here is one code to extracting data from hdf5 file.


I got concept of HDF5 are

  • Hierarchical Data format version 5
  • Standard for sorting large quantities of numerical data
  • Datasets can be hundred of gigabytes of terabytes
  • HDF5 can scale to exabytes
# Get the HDF5 group: group
group = data['strain']

# Check out keys of group
for key in group.keys():

# Set variable equal to time series data: strain
strain = data['strain']['Strain'].value

# Set number of time points to sample: num_samples
num_samples = 10000

# Set time vector
time = np.arange(0, 1, 1/num_samples)

# Plot data
plt.plot(time, strain[:num_samples])
plt.xlabel('GPS Time (s)')
Enter fullscreen mode Exit fullscreen mode

Discussion (0)

Editor guide