Hi Eric, A Tuesday 18 November 2008, Eric Bruning escrigué: > Is the extended slice attribute notation supported? It is mentioned > on the http://www.pytables.org/moin/HintsForSQLUsers#Updatingdata, > and is said to allow writing data to arbitrary row coordinates, like > so: > > rows = [ > ('foo', 0.0, 0.0, 150.0), > ('bar', 0.5, 0.0, 100.0), > ('foo', 1.0, 1.0, 25.0) > ] > rownos = [2, 735, 371913476] > tbl[rownos] = rows > > I get ValueError: Non-valid index or slice: [3, 4, 5] (table.py, > line 1709, pytables 2.0.3) when I try to run the following code: > h5=tables.openFile('idx-std-1.x.h5', 'a') > h5.root.table[[3,4,5]] = [('col1',3,4,5), ('col2',5,6,7), > ('col1',5,6,7)]
No, it is not. It has been in my plans for long time to add this, but not done yet. I've added a ticket about this: http://www.pytables.org/trac/ticket/198 so as I not forget this for too long again ;-) Also I've updated the hints document to say that extended slicing will be added in the future. Thanks for bringing this to my attention. > If extended slicing isn't supported, is there a better way to deal > with sparse indices than: > for row_id, datum in zip(row_ids, coldata): > col[row_id] = datum Yes, there is. You can make use of the .itersequence() iterator combined with the .update() method: for i, row in enumerate(tbl.itersequence(row_ids)): row['col'] = coldata[i] row.update() tbl.flush() This method has the advantage that the update is made by using an internal buffer, so it will be faster in general (specially when you modify a lot of rows) than the one you suggested. Hope that helps, -- Francesc Alted ------------------------------------------------------------------------- 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