On 02/08/2013 02:28 PM, Adrian Klaver wrote:
> In the interim I went the dbf.is_deleted(record) route. I am unclear as
> to how to make the index method work, in particular where I create the
> index and on what?
table = dbf.Table('some_table')
table.open()
active_records = table.create_index(lambda rec:
dbf.recno(rec) if not dbf.is_deleted(rec) else dbf.DoNotIndex
)
for record in active_records:
# do something with your definitely not deleted record :)
The `dbf.recno(rec)` portion can be substituted with whatever sorting
criteria you desire; and, of course, it's clearer if you use a `def`
function instead of a `lambda`:
def active_employees(rec):
"sorts employees by department, last_name; ignores deleted records"
if dbf.is_deleted(rec):
return dbf.DoNotIndex
return rec.department, rec.last_name
active_employee_index = table.create_index(active_employees)
Hope this helps.
~Ethan~1