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

Discussion in 'Python' started by Neville C. Dempsey, Jun 12, 2005.

  1. #!/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
    """
     
    Neville C. Dempsey, Jun 12, 2005
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Homer J Simpson
    Replies:
    17
    Views:
    10,317
    hernanbalda
    Sep 18, 2008
  2. Twist Around

    Zebra Printing Language

    Twist Around, Oct 23, 2003, in forum: Python
    Replies:
    2
    Views:
    5,517
    George Kinney
    Oct 24, 2003
  3. Skip Montanaro
    Replies:
    1
    Views:
    412
    Bengt Richter
    Jun 26, 2005
  4. =?Utf-8?B?UGF1bCBCdXp6YSwgb2xkc3RlciB1c2luZyBuZXcg

    Print Label on LOCAL Zebra Printer from WEBSITE Inventory DB

    =?Utf-8?B?UGF1bCBCdXp6YSwgb2xkc3RlciB1c2luZyBuZXcg, Apr 25, 2007, in forum: ASP .Net
    Replies:
    4
    Views:
    1,399
    Alexey Smirnov
    Apr 26, 2007
  5. Replies:
    0
    Views:
    358
Loading...

Share This Page