From: Francesc A. <fa...@ca...> - 2005-06-15 10:48:50
|
[I'm CC-ing this to pytables-users. Hope you don't mind] A Wednesday 15 June 2005 11:09, v=E0reu escriure: > Hi Francesc! > > I have contacted you before about using PyTables for storing simulation > data. We have decided to make use of your program since it has so many > powerful features. Nevertheless I have a question regarding the creation = of > tables. Suppose we have a class like this (taken from your example): > > class Particle(IsDescription): > name =3D StringCol(16) # 16-character String > idnumber =3D Int64Col() # Signed 64-bit integer > ADCcount =3D UInt16Col() # Unsigned short integer > TDCcount =3D UInt8Col() # unsigned byte > grid_i =3D Int32Col() # integer > grid_j =3D IntCol() # integer (equivalent to Int32Col) > pressure =3D Float32Col() # float (single-precision) > energy =3D FloatCol() # double (double-precision) > > and later on we create a table with: > > table =3D h5file.createTable(group, 'readout', Particle, "Readout example= ") > > The third parameter of the createTable function is the name of the class, > in this example Particle - a user record for characterizing 8 attributes > (name, idnumber, ADCcount …), which correspond to 8 columns of a > table. Now, suppose I want to write a new function for dealing with tables > where a user can specify an arbitrary number of columns with different da= ta > types. How can I make a custom class (Particle in this example) to change > its number of attributes corresponding to user request/input of the number > of columns that it wishes to have? > I hope I was clear enough. I am not sure to completely understand you, but perhaps creating a table using a dictionary as a description would be enough for you? Look at: http://pytables.sourceforge.net/html-doc/x912.html#secondExample for an example of using dictionaries as table descriptors. HTH, =2D-=20 >0,0< Francesc Altet =A0 =A0 http://www.carabos.com/ V V C=E1rabos Coop. V. =A0=A0Enjoy Data "-" |