A Wednesday 08 December 2010 17:54:07 Francesc Alted escrigué:
> Hi Andrey,
> 
> A Wednesday 08 December 2010 14:59:52 Andrey Sobolev escrigué:
> > Could anyone please suggest how to safely remove a row from a
> > vlarray?
> > 
> > A question seems trivial but looks like there is no standard method
> > for that.
> > I was trying to find answer within pytables-archives but maybe
> > missed it, sorry.
> 
> Sorry, but removing a row from a VLArray (Array in general) is not
> implemented (the Table object is the only one supporting it).
> 
> The ultimate reason for this is that HDF5 itself does not support
> such a operation, so that must be faked by PyTables.  The method is
> relatively easy: move the rows after the one to be removed one
> position up, and then truncate the dataset (see
> `Leaf.truncate(size)`).

Uh, I've just realized that this procedure is not going to work with 
VLArray objects, as you cannot (due to a HDF5 limitation) modify the 
contents of an existing entry with another value (that may potentially 
have a larger number of items).

So, I'm afraid that your best bet is to copy all elements (except the 
one that you want to remove) into a brand-new VLArray, remove the 
original VLArray and then move the new node into the original one.

If this is unacceptable in terms of speed, the you should try to think 
how to avoid row removals in VLArrays.  For example, if your goal is 
allow variable length entries in Tables, then I'd suggest to add a new 
column in the Table to keep track of the row number where the variable 
length is located in the VLArray.

Cheers,

-- 
Francesc Alted

------------------------------------------------------------------------------
This SF Dev2Dev email is sponsored by:

WikiLeaks The End of the Free Internet
http://p.sf.net/sfu/therealnews-com
_______________________________________________
Pytables-users mailing list
Pytables-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pytables-users

Reply via email to