嵌套的pytables

时间:2012-10-24 21:20:12

标签: pytables

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

h5f.createTable( '/', '表',{ 'COL1':Float64Col(位置= 0), 'COL2':StringCol(16,POS = 1)})

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

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

感谢您的帮助!

1 个答案:

答案 0 :(得分: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)