slicing a bsddb table, eg. for rec in bsddb["AArdvark":"zebra"]:print rec

N

Neville C. Dempsey

#!/bin/env python
import bsddb

test=bsddb.btopen("test.tbl")
for m in "JFMATQPHSOND":
test[m]="Profit for month "+m+" $1B"

def subyear_report(record_selection):
for data in record_selection.iteritems(): print data

# I was expecting a slice of an index file to yield a
# generator so not all the records need to be read from disk....
subyear_report(test["Apr":"Sep"])

"""
I have tried a few ideas.... but is there a simple way to convert this
["Apr":"Sep"] slice of a file into a generator of the requested records?

(I tried UserDict and got a bit further...)

Any hints?

ThanX
NevilleDNZ
"""
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top