A Thursday 31 July 2008, Eric Jonas escrigué: > I frequently find myself using compound data types as attributes on > tables, but unfortunately these are unsupported in pytables at the > moment. How hard would it be to add simple non-recursive read > capabilities to pytables for this particular attribute style? I've > been spending quite a lot of time lately with both python, numpy at > the C level, and pyrex, so I might actually be able to help.
Well, if you have this kind of experience, I think you can have a look at the ``Table.getNestedType()`` (in src/tableExtension.pyx) that reads a potentially nested datatype in HDF5 and return a nested dictionary as the raw description of it. With it, you can get the full-fledged description object with the next call: full_descr = tables.description.Description(dict_descr) After that, the NumPy dtype can be obtained in: dtype_descr = self.description._v_dtype And with this, you can easily get a NumPy container for the attribute. Then, look at the ``AttributeSet._g_getAttr()`` (in src/hdf5Extension.pyx) in order to figure out how to populate the container with the info from the HDF5 attribute (should be easy). This is, more or less, the procedure to follow. All the important methods mentioned here are documented with docstrings and with comments. Please read them carefully as they will hopefully provide you with clues for get your job done. Good luck! -- Francesc Alted Freelance developer Tel +34-964-282-249 ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Pytables-users mailing list Pytables-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/pytables-users