A Friday 15 February 2008, Kevin Christman escrigué: > sorry about the mangled table and un-indented code. Here is the > formatting preserved: > http://docs.google.com/View?docid=dcmrvf8_31cfvc7vfs > > So I recognize that row.append() should be applied only *once*, and > that my current code is bad. However, my question then is *how* does > one fill the subrows with data? For example, after filling in the > sub-sub-row with 25% and 80% how do I proceed to fill in the next > sub-sub-row with 50% and 85%?
Sorry, but I don't get the question. Here it is an example on how to fill nested records: ************************************************************ class Info(IsDescription): """A sub-structure of Test""" _v_pos = 2 # The position in the whole structure name = StringCol(10) value = Float64Col(pos=0) colors = Enum(['red', 'green', 'blue']) class NestedDescr(IsDescription): """A description that has several nested columns""" color = EnumCol(colors, 'red', base='uint32') info1 = Info() class info2(IsDescription): _v_pos = 1 name = StringCol(10) value = Float64Col(pos=0) class info3(IsDescription): x = Float64Col(dflt=1) y = UInt8Col(dflt=1) fileh = openFile(filename, "w") table = fileh.createTable(fileh.root, 'table', NestedDescr) # Fill the table with some rows row = table.row for i in range(10): row['color'] = colors[['red', 'green', 'blue'][i%3]] row['info1/name'] = "name1-%s" % i row['info2/name'] = "name2-%s" % i row['info2/info3/y'] = i # All the rest will be filled with defaults row.append() *************************************************************** This is an excert of the examples/nested-tut.py in the PyTables distribution. Also, my advice is you to read the tutorial about the usage of nested tables in Users' Guide (section 3.7). Hope this helps, -- >0,0< Francesc Altet http://www.carabos.com/ V V Cárabos Coop. V. Enjoy Data "-" ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ Pytables-users mailing list Pytables-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/pytables-users