Table.copy() createparents=True behavior

10 views
Skip to first unread message

Ken Walker

unread,
Jul 9, 2020, 5:09:41 PM7/9/20
to pytables-users
I am using Table.copy() to copy a Table from a source file to a new/target file.
The desired table sits several group levels below the root level.
Imagine something like this
h5f1.root.Group1.SubGroup2.SubGroup3.SubGroup4.Table1
(or /Group1/SubGroup2/SubGroup3/SubGroup4/Table1)

I want to copy Table1 to the same hierarchical position in the destination file.
I hoped that the createparents=True argument would allow me do that (without having to first create the intermediate Groups).
This is what I tried:
source_table = h5f1.root.Group1.SubGroup2.SubGroup3.SubGroup4.Table1

source_table
.copy(newparent=h5f2.root.Group1.SubGroup2.SubGroup3.SubGroup4, createparents=True)

I get this error message:
NoSuchNodeError: group ``/`` does not have a child named ``Group1``


Is there a way to have createparents do that?

I tried this. It creates Table1 at the root level:
source_table.copy(newparent=h5f2.root, createparents=True)

And this works after creating the Group Hierarchy in the target file with createparents.
target_group = h5f2.create_group(where='/Group1/SubGroup2/SubGroup3',
                                 
name='SubGroup4', createparents=True)
source_table
.copy(newparent=target_group)

Am I missing something with Table.copy() and createparents?
Thanks!
-Ken
Reply all
Reply to author
Forward
0 new messages