I am looking for a sample code which can convert .h5 files to csv or tsv. I have to read .h5 and output should be csv or tsv.
Sample code would be much appreciated,p
import numpy as np
import h5py
with h5py.File('chunk0003.hdf5','r') as hf:
print('List of arrays in this file: \n', hf.keys())
### This lists arrays in the file [u'_self_key', u'chrms1', u'chrms2', u'cuts1', u'cuts2', u'misc', u'strands1', u'strands2']
r1 = h5py.File('chunk0003.hdf5','r')
a = r1['chrms1'][:]
b = r1['chrms2'][:]
c = r1['cuts1'][:]
d = r1['cuts2'][:]
e = r1['strands1'][:]
f = r1['strands2'][:]
r1.close()
table=np.array([a,b,c,d,e,f])
table2=table.transpose()
np.savetxt('chunk0003.txt',table2,delimiter='\t')