1import time
2import numpy as np
3import h5py
4import os
5
6arr = np.random.randn(1000)
7
8with h5py.File('groups.hdf5', 'w') as f:
9 g = f.create_group('Base_Group')
10 d = g.create_dataset('default', data=arr)
11
12 g.attrs['Date'] = time.time()
13 g.attrs['User'] = 'Me'
14
15 d.attrs['OS'] = os.name
16
17 for k in g.attrs.keys():
18 print('{} => {}'.format(k, g.attrs[k]))
19
20 for j in d.attrs.keys():
21 print('{} => {}'.format(j, d.attrs[j]))