Files
ieemoo-ai-conpurchase/utils/opfile.py
2023-06-25 13:55:22 +08:00

25 lines
616 B
Python

import h5py, os
from floder.config import cfg
def writef(uuid, num_id, feature):
fname = os.sep.join([cfg.hFile, uuid+'.h5'])
if not os.path.exists(fname):
f = h5py.File(fname, 'w')
f[str(num_id)] = feature
else:
f = h5py.File(fname, 'a')
f[str(num_id)] = feature
print('>>>>>>>have been write')
f.close()
def readf(uuid, num_id):
fname = os.sep.join([cfg.hFile, uuid+'.h5'])
f = h5py.File(fname, 'r')
value = f[str(num_id)][:]
f.close()
return value
def removef(uuid):
fname = os.sep.join([cfg.hFile, uuid+'.h5'])
os.remove(fname)