假设您正在将一个字典传递给pytable构造函数:
h5f.createTable('/',‘表’,{'col1':Float64Col(pos=0),'col2':StringCol(16,pos=1)})
我有以下三个与嵌套pytables相关的初学者问题:
1)如何使用字典描述符来创建嵌套pytable? 2)如何为嵌套列分配位置?如果顶级列的位置为pos=1,是否从0开始对其子列进行编号? 3)如何将行分配给嵌套列?
感谢您的帮助!
发布于 2013-02-28 06:24:49
我一直在使用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)https://stackoverflow.com/questions/13057924
复制相似问题