Answers for "opening h5 files in python"

1

how to use h5 file in python

import time
import numpy as np
import h5py
import os

arr = np.random.randn(1000)

with h5py.File('groups.hdf5', 'w') as f:
    g = f.create_group('Base_Group')
    d = g.create_dataset('default', data=arr)

    g.attrs['Date'] = time.time()
    g.attrs['User'] = 'Me'

    d.attrs['OS'] = os.name

    for k in g.attrs.keys():
        print('{} => {}'.format(k, g.attrs[k]))

    for j in d.attrs.keys():
      print('{} => {}'.format(j, d.attrs[j]))
Posted by: Guest on June-28-2021
1

how to read hdf5 file in python

store = HDFStore('dataset.h5')
#import hdfStore from pandas
Posted by: Guest on August-16-2020

Code answers related to "opening h5 files in python"

Python Answers by Framework

Browse Popular Code Answers by Language