0

Suppose you are passing a dictionary to the pytable constructor:

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

I have the following three beginner's questions related to nested pytables:

1) How do you use a dictionary descriptor for creating a nested pytable? 2) How do you assign positions for the nested columns? If the top-level column has position pos=1, do you start numbering its subcolumns from 0? 3) How do you assign rows to the nested column?

Thanks for helping!

1 Answers1

0

I've been dynamically creating pytables description using python type(). This should at least get you going...

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)
bcollins
  • 3,379
  • 4
  • 19
  • 35