以前考虑这个功能时一直没有找到接口,以为要自己先创建一个同样的dataset,再删除老的dataset。今天五一中看到group的接口中有一个:
- move(source,
dest)
-
Move an object or link in the file. If source is a hard link, thiseffectively renames the object. If a soft or external link, thelink itself is moved.
Parameters: - source (String) – Name of object or link to move.
- dest (String) – New location for object or link.
于是用一个文件测试了一下,竟然成功!
import h5py
f = h5py.File('e:\\test.h5')
grp = f['/Trans']
grp.move('20141031', '20150101')
f.close()
注意move接口中的两个参数就是源dataset和目的dataset。