Hi List,

I ran into unexpected behavior when iterating over rows in a table (PyTables version '2.2a2').

The attached script shows the problem (minimal example), but, briefly: if one iterates over rows in a table, and checks in the loop if the row has a certain key, the iterator will jump to the last row and skip all other rows.

I admit checking for a key is a stupid thing to do (one should look at the table colnames before the loop), and I don't even know if the row type is intended to support this. But this aside, is the iterator behavior shown here a bug?

Cheers, Gabriel
import numpy as np
import tables as tb

dtype = np.dtype([('number', np.int)])
structar = np.arange(10).view(dtype)

h5f = tb.openFile('testfile.h5','w')
t = h5f.createTable(h5f.root, 'testtable', structar)
h5f.flush()

print "this works as expected"
for row in t.iterrows():
    print row

print "this doesn't"
for row in t.iterrows():
    if 'number' in row:
        pass
    print row
    
h5f.close()
    


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Pytables-users mailing list
Pytables-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pytables-users

Reply via email to