A Wednesday 21 May 2008, Glenn escrigué: > Francesc Alted <falted <at> pytables.org> writes: > > A Monday 19 May 2008, Glenn escrigué: > > > I am working on refining some algorithms to process some spectral > > > data I have stored in an h5 file using PyTables. The data is > > > stored as an EArray. As I work on my algorithm, I'd like to store > > > intermediate computations in the same h5 file. The trouble I am > > > having is as follows: > > > I create a new EArray to store the intermediate result > > > Then I iterate through my data, appending my results to the > > > EArray If I then realize I've made a mistake in computing the > > > intermediate result, I have to do something like: > > > try: > > > res = fh.getNode(grp, 'res') > > > res.remove() > > > except: > > > pass > > > res = fh.createEArray(grp, 'res', Float32Atom(), (0,512)) > > > > > > in order to remove the old array so that I can start fresh. This > > > seems to be slow and cumbersome. > > > Is there any better way to do this? Perhaps a way to tell the > > > EArray to start at the beginning again so subsequent append > > > operations overwrite old data? > > > > EArray objects supports data overwriting: > > > > res[slice] = your_new_data > > > > So, you can re-write your data until the point you've made the > > mistake, and then continue to append. > > > > If you know the final number of rows on your disk-array, you may > > find easy to use a CArray and then use regular assignments to fill > > it (as if it were an in-memory array). > > > > Hope that helps, > > Thank you for the suggestion, but this also seems clumsy, because my > routine still needs to parts, one to replace the original values, and > then a second to add the new values. Most often, I make an error in > the first row or two, so the EArray has one incorrect row that I need > to reassign, so it seems like a lot of extra code just to treat the > first row or two as a special case. To me, it would be ideal if the > indexing notation could be extended to allow > res[length_of_growable_dimension] = new_data to be equivalent to > res.append(new_data). That is, if you index one beyond the end of the > growable dimension, it automatically creates a new row. > Thank you again, > Glenn > > > > --------------------------------------------------------------------- >---- 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
Nice suggestion. Added a ticket so as to not forget it: http://www.pytables.org/trac/ticket/170 Regards, -- Francesc Altet Freelance developer Tel +34-964-282-249 ------------------------------------------------------------------------- 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