Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > filter is Python

Reply
Thread Tools

filter is Python

 
 
Wiebke Pätzold
Guest
Posts: n/a
 
      07-30-2003
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
 
Reply With Quote
 
 
 
 
Brian Kelley
Guest
Posts: n/a
 
      07-30-2003
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)


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
What is Anti-Spam Filter.(thunderbird spam filter) zax75 Java 1 03-28-2008 06:43 AM
"rec.photo.digital.txt" Filter File Posted Online (for newsreadersthat can import a list of e-mail addresses to filter out) SMS 斯蒂文• å¤ Digital Photography 2 11-25-2007 11:00 AM
Polarising filter with UV filter? Stimp Digital Photography 23 11-17-2006 11:51 AM
to filter of not to filter Ken Digital Photography 2 12-23-2005 12:45 PM
UV Protector filter vs. Skylight filter? john Digital Photography 8 06-26-2004 03:44 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57