0

假设您将字典传递给 pytable 构造函数:

h5f.createTable('/','table',{'col1':Float64Col(pos=0),'col2':StringCol(16,pos=1)})

我有以下三个与嵌套 pytables 相关的初学者问题:

1)如何使用字典描述符来创建嵌套的 pytable?2)如何为嵌套列分配位置?如果顶级列的位置为 pos=1,您是否从 0 开始对其子列进行编号?3)如何将行分配给嵌套列?

感谢您的帮助!

4

1 回答 1

0

我一直在使用 python type() 动态创建 pytables 描述。这至少应该让你继续......

from tables import *

h5_file = openFile('test_nested_table.h5', 'w')

nested_table_fields = {}
nested_table_fields['x'] = Float64Col(dflt=1, pos=0)
nested_table = type('nested_table', (IsDescription,), nested_table_fields)

main_table_fields = {}
main_table_fields['y'] = Float64Col(dflt=1, pos=0)
main_table_fields['nested_table'] = nested_table
main_table = type('main_table', (IsDescription,), main_table_fields)

h5_table = h5_file.createTable('/', 'nested_table_example', main_table)
print repr(h5_table)
于 2013-02-27T22:24:48.827 回答