From: Ivan V. i B. <iv...@ca...> - 2005-03-01 13:11:31
|
On Sun, Feb 27, 2005 at 03:24:36AM -0500, travlr wrote: > Hi Francesc, >=20 > The reference for walkGroups() says:=20 > Iterator that returns the list of Groups (not Leaves) hanging from where. >=20 > From this description, the list returned should not include the "/" > group if that is what is labled for where. -->walkGroups(where=3D"/") Yes, you're right on that. In fact, the documentation for File.walkGroups() and Group._f_walkGroups() was fixed some time ago to reflect that detail. It will show up in PyTables 1.0. If you want to get the updated documentation, you can get a development snapshot from PyTables at http://www.carabos.com/downloads/pytables/snapshots . >=20 > The tutorial provides great & diverse examples of how to attain the > public attributes of the object tree, but does not express how into > instantiate the leaves, via iteration, so they can be used for numeric > processing. For instance I'm trying to loop through the groups hanging > from "root", to work with the arrays contained within. You might be interested in File.listNodes() and File.walkNodes(). The first lists direct children of a specific node. The second recurses into children to get all descendent nodes. >=20 > One version I've tried: >=20 > import tables as ta > f =3D ta.openFile('/H5/ESdat.h5','r') >=20 > for group in f.walkGroups(where=3D"/"): > g =3D eval("f.root."+group._v_name) # You can directly use 'group' here instead of 'g'. > ap =3D g.AP.read() > aS =3D g.AS.read() > p1 =3D g.P1.read() > v1 =3D g.V1.read() > a1 =3D g.A1.read() > ud =3D g.UD.read() >=20 > ... do some things... > f.close() >=20 > I've tried many possible ways to iterate through the file and > auto-magically perform tasks. A simple example of Group._f_listNodes(): # For every group which descends from '/' (including it). for group in f.walkGroups('/'): # For every leaf in that group. for leaf in group._f_listNodes(classname =3D 'Leaf'): print leaf._v_pathname, leaf.read() Hope this helps. Regards, Ivan import disclaimer --=20 Ivan Vilata i Balaguer >qo< http://www.carabos.com/ C=E1rabos Coop. V. V V Enjoy Data "" |