A Tuesday 19 February 2008, Kevin Christman escrigué:
> I am having problems removing rows.  Since removeRows() doesn't
> accept a list of indices to be removed (it only accepts a single
> value or a range), I tried to remove the rows one by one, where
> DryExp is my table:
>
> listofBadNums = ['NJ451','AJ322','B321']    #actually this is just a
> short test list for row in DryExp:
>     if row['CatalogNum'] in listofBadNums:
>         DryExp.removeRows(row.nrow)
> DryExp.flush()
>
> I also tried moving DryExp.flush() inside the loop, but in either
> case I got the following error message:
>
> Traceback (most recent call last):
>   File "D:\tablem.py", line 46, in <module>
>     for row in DryExp:
>   File "tableExtension.pyx", line 801, in tableExtension.Row.__next__
>   File "tableExtension.pyx", line 951, in
> tableExtension.Row.__next__general File "tableExtension.pyx", line
> 548, in tableExtension.Table._read_records HDF5ExtError: Problems
> reading records.
>
> So I suspect the problem is that DryExp is changing every time.

Yes, that's exactly the problem.  You can't issue an operation that 
modifies the number of rows of a table in the middle of a table Row 
iterator.  I'll try to document this later on.

What you can do is (untested):

listofBadNums = ['NJ451','AJ322','B321']
listofBadRows = []
for row in DryExp:
    if row['CatalogNum'] in listofBadNums:
        listofBadRows.append(row.nrow)
for i in listofBadRows:
    DryExp.removeRows(i)

Hope this helps,

-- 
>0,0<   Francesc Altet     http://www.carabos.com/
V   V   Cárabos Coop. V.   Enjoy Data
 "-"

-------------------------------------------------------------------------
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

Reply via email to