filter is Python

W

Wiebke Pätzold

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
 
B

Brian Kelley

Wiebke said:
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)
 

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,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top