Rename dataset

6,072 views
Skip to first unread message

Jonathan Tu

unread,
Apr 23, 2011, 8:21:35 PM4/23/11
to h5...@googlegroups.com

Hi,

 

Is there an easy way to rename a dataset?  I have a few hdf5 files where I would like to rename the datasets and change the attributes to be more descriptive.  I know I could simply copy the internal data, create a new dataset, and delete the old one.  But I thought there might be a built-in method of some sort to do this more easily.

 

 

 

 

Jonathan Tu

Andrew Collette

unread,
Apr 23, 2011, 10:39:35 PM4/23/11
to h5...@googlegroups.com
Hi,

There's no specific "rename" function, but it's easy to do. Suppose
you have a dataset named "one" and want to rename it to "two":

>>> myfile["two"] = myfile["one"]
>>> del myfile["one"]

This shouldn't result in any copying of data, as only the names of the
datasets are updated in the file.

Andrew

Reply all
Reply to author
Forward
0 new messages