filter is Python

Discussion in 'Python' started by Wiebke Pätzold, Jul 30, 2003.

  1. Hi all!

    I have to work with MetaKit. My job is it to filter. For example: If I
    search for the initial letter "P", the programm should all results
    print with this characteristic.
    Couls somebody help me with this task?

    Wiebke
    Wiebke Pätzold, Jul 30, 2003
    #1
    1. Advertising

  2. Wiebke Pätzold

    Brian Kelley Guest

    Wiebke Pätzold wrote:
    > Hi all!
    >
    > I have to work with MetaKit. My job is it to filter. For example: If I
    > search for the initial letter "P", the programm should all results
    > print with this characteristic.
    > Couls somebody help me with this task?
    >
    > Wiebke


    The metakit list is probably the place for this. See equi4.com for
    instructions. That being said:


    I assume you are filtering a table/view looking at some column. Let's
    say the table is "foo" and the column is "bar".

    def myfilter(row):
    return row.bar[0] == "P"

    # return the matching indices
    indices = view.filter(myfilter)
    # return a new view with only the matching rows
    newview = view.remapwith(indices)

    Here is a full example:
    import metakit

    storage = metakit.storage()
    vw = storage.getas("test[bar:S]")

    data = """My dog has fleas but he is a very good Pooch.
    Sometimes he likes to Play""".split()

    for d in data:
    vw.append((d,))

    def myfilter(row):
    return row.bar[0] == "P"

    indices = vw.filter(myfilter)
    metakit.dump(indices)

    newvw = vw.remapwith(indices)
    metakit.dump(newvw)
    Brian Kelley, Jul 30, 2003
    #2
    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. revyakin

    python spam filter: random words?

    revyakin, Aug 11, 2003, in forum: Python
    Replies:
    4
    Views:
    424
    Marc Wilson
    Aug 12, 2003
  2. Tony Meyer

    RE: python spam filter: random words?

    Tony Meyer, Aug 11, 2003, in forum: Python
    Replies:
    1
    Views:
    482
    Brandon J. Van Every
    Aug 11, 2003
  3. Peter Mutsaers

    Python slow for filter scripts

    Peter Mutsaers, Oct 28, 2003, in forum: Python
    Replies:
    13
    Views:
    514
    John J. Lee
    Nov 5, 2003
  4. Xah Lee
    Replies:
    11
    Views:
    507
    Tad McClellan
    Jan 18, 2005
  5. zax75
    Replies:
    1
    Views:
    1,087
Loading...

Share This Page