Discussion:
[pytables-users] Renaming a group?
Christopher Turnbull
2016-03-10 10:25:07 UTC
Permalink
Hi, could someone please tell me how to rename a group?

This probably seems like a dumb question- so do you know anywhere I could
learn pytables? I'm having problems following the tutorial on their
website...
--
You received this message because you are subscribed to the Google Groups "pytables-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pytables-users+***@googlegroups.com.
To post to this group, send an email to pytables-***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Christopher Turnbull
2016-03-10 11:33:15 UTC
Permalink
from tables import * h5f = open_file('/home/chris/Chris
Hunter/sensors_data.h5','a')
print h5f

/home/chris/Chris Hunter/sensors_data.h5 (File) ''
Last modif.: 'Thu Mar 10 10:10:47 2016'
Object Tree:
/ (RootGroup) ''
/home (Group) ''
/home/chris (Group) ''
/home/chris/Chris Hunter (Group) ''
/home/chris/Chris Hunter/New_header_Alphasense_ECC_box_merged_240615_210815.csv
(Table(504008,)) ''



I'm trying to rename the group 'Chris Hunter'


h5f.root.home.chris.Chris Hunter._f_rename('a')

File "<ipython-input-35-bcd838c32dc2>", line 1
h5f.root.home.chris.Chris Hunter._f_rename('a')
^
SyntaxError: invalid syntax
--
You received this message because you are subscribed to the Google Groups "pytables-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pytables-users+***@googlegroups.com.
To post to this group, send an email to pytables-***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Francesc Alted
2016-03-10 12:02:25 UTC
Permalink
Hi Christopher,

You cannot use invalid Python variable names in combination with the
natural name approach. Instead, use File.rename_node():

http://www.pytables.org/usersguide/libref/file_class.html?highlight=rename#tables.File.rename_node

BTW, the quick search box in the left frame of the documentation is your
friend, so don't hesitate to use it extensively.

Francesc
Post by Christopher Turnbull
from tables import * h5f = open_file('/home/chris/Chris
Hunter/sensors_data.h5','a')
print h5f
/home/chris/Chris Hunter/sensors_data.h5 (File) ''
Last modif.: 'Thu Mar 10 10:10:47 2016'
/ (RootGroup) ''
/home (Group) ''
/home/chris (Group) ''
/home/chris/Chris Hunter (Group) ''
/home/chris/Chris Hunter/
New_header_Alphasense_ECC_box_merged_240615_210815.csv (Table(504008,)) ''
I'm trying to rename the group 'Chris Hunter'
h5f.root.home.chris.Chris Hunter._f_rename('a')
File "<ipython-input-35-bcd838c32dc2>", line 1
h5f.root.home.chris.Chris Hunter._f_rename('a')
^
SyntaxError: invalid syntax
--
You received this message because you are subscribed to the Google Groups
"pytables-users" group.
To unsubscribe from this group and stop receiving emails from it, send an
For more options, visit https://groups.google.com/d/optout.
--
Francesc Alted
--
You received this message because you are subscribed to the Google Groups "pytables-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pytables-users+***@googlegroups.com.
To post to this group, send an email to pytables-***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Christopher Turnbull
2016-03-15 16:16:31 UTC
Permalink
h5f.rename_node('/home/chris/Chris Hunter','newname')


---------------------------------------------------------------------------NoSuchNodeError Traceback (most recent call last)<ipython-input-30-9b75f53baacd> in <module>()----> 1 h5f.rename_node('/home/chris/Chris Hunter','newname')
/home/chris/anaconda2/lib/python2.7/site-packages/tables/file.pyc in rename_node(self, where, newname, name, overwrite) 1662 """ 1663 -> 1664 obj = self.get_node(where, name=name) 1665 obj._f_rename(newname, overwrite) 1666
/home/chris/anaconda2/lib/python2.7/site-packages/tables/file.pyc in get_node(self, where, name, classname) 1614 # Now we have the definitive node path, let us try to get the node. 1615 if node is None:-> 1616 node = self._get_node(nodepath) 1617 1618 # Finally, check whether the desired node is an instance
/home/chris/anaconda2/lib/python2.7/site-packages/tables/file.pyc in _get_node(self, nodepath) 1553 return self.root 1554 -> 1555 node = self._node_manager.get_node(nodepath) 1556 assert node is not None, "unable to instantiate node ``%s``" % nodepath 1557
/home/chris/anaconda2/lib/python2.7/site-packages/tables/file.pyc in get_node(self, key) 434 435 if self.node_factory:--> 436 node = self.node_factory(key) 437 self.cache_node(node, key) 438
/home/chris/anaconda2/lib/python2.7/site-packages/tables/group.pyc in _g_load_child(self, childname) 1184 childname = join_path(self._v_file.root_uep, childname) 1185 # Is the node a group or a leaf?-> 1186 node_type = self._g_check_has_child(childname) 1187 1188 # Nodes that HDF5 report as H5G_UNKNOWN
/home/chris/anaconda2/lib/python2.7/site-packages/tables/group.pyc in _g_check_has_child(self, name) 400 raise NoSuchNodeError( 401 "group ``%s`` does not have a child named ``%s``"--> 402 % (self._v_pathname, name)) 403 return node_type 404
NoSuchNodeError: group ``/`` does not have a child named ``/home/chris/Chris Hunter``



So that didn't work either! I can't access my table in order to do anything with it, why can't I rename the node?
--
You received this message because you are subscribed to the Google Groups "pytables-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pytables-users+***@googlegroups.com.
To post to this group, send an email to pytables-***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
David Dotson
2016-03-16 05:13:46 UTC
Permalink
Perhaps try something like `h5f.rename_node('/home/chris', 'new name', name='Chris Hunter')`. See the docstring from `tables.File.get_node` for details on the way these arguments typically go for accessing nodes.

David
Post by Christopher Turnbull
h5f.rename_node('/home/chris/Chris Hunter','newname')
---------------------------------------------------------------------------
NoSuchNodeError Traceback (most recent call last)
<ipython-input-30-9b75f53baacd> in <module>() ----> 1h5f.rename_node('/home/chris/Chris Hunter','newname')/home/chris/anaconda2/lib/python2.7/site-packages/tables/file.pyc in rename_node(self, where, newname, name, overwrite) 1662 """ 1663 -> 1664obj = self.get_node(where, name=name)1665 obj._f_rename(newname, overwrite)1666 /home/chris/anaconda2/lib/python2.7/site-packages/tables/file.pyc in get_node(self, where, name, classname) 1614 # Now we have the definitive node path, let us try to get the node.1615 if node is None:-> 1616node = self._get_node(nodepath)1617 1618 # Finally, check whether the desired node is an instance/home/chris/anaconda2/lib/python2.7/site-packages/tables/file.pyc in _get_node(self, nodepath) 1553 return self.root1554 -> 1555node = self._node_manager.get_node(nodepath)1556 assert node is not None, "unable to instantiate node ``%s``" % nodepath1557 /home/chris/anaconda2/lib/python2.7/site-packages/tables/file.pyc in get_node(self, key) 434 435 if self.node_factory:--> 436node =
self.node_factory(key)437 self.cache_node(node, key)438 /home/chris/anaconda2/lib/python2.7/site-packages/tables/group.pyc in _g_load_child(self, childname) 1184 childname = join_path(self._v_file.root_uep, childname)1185 # Is the node a group or a leaf?-> 1186node_type = self._g_check_has_child(childname)1187 1188 # Nodes that HDF5 report as H5G_UNKNOWN/home/chris/anaconda2/lib/python2.7/site-packages/tables/group.pyc in _g_check_has_child(self, name) 400 raise NoSuchNodeError( 401 "group ``%s`` does not have a child named ``%s``"--> 402% (self._v_pathname, name)) 403 return node_type404 NoSuchNodeError: group ``/`` does not have a child named ``/home/chris/Chris Hunter``
So that didn't work either! I can't access my table in order to do anything with it, why can't I rename the node?
--
You received this message because you are subscribed to the Google Groups "pytables-users" group.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "pytables-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pytables-users+***@googlegroups.com.
To post to this group, send an email to pytables-***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Christopher Turnbull
2016-03-16 09:03:53 UTC
Permalink
Tried that, however now this error comes up. I think it must be something
to do with the whitespace in 'Chris Hunter' ?

NoSuchNodeError: group ``/`` does not have a child named ``/home/chris/Chris Hunter``
--
You received this message because you are subscribed to the Google Groups "pytables-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pytables-users+***@googlegroups.com.
To post to this group, send an email to pytables-***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...