在hdf5文件中重命名dataset

来源:互联网 发布:仿m淘宝登录注册 编辑:程序博客网 时间:2024/05/16 04:52


以前考虑这个功能时一直没有找到接口,以为要自己先创建一个同样的dataset,再删除老的dataset。今天五一中看到group的接口中有一个:

move(source,dest)

Move an object or link in the file. If source is a hard link, thiseffectivelyrenames 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 h5pyf = h5py.File('e:\\test.h5')grp = f['/Trans']grp.move('20141031', '20150101')f.close()

注意move接口中的两个参数就是源dataset和目的dataset。


0 0