473,396 Members | 1,996 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

filter is Python

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
Jul 18 '05 #1
1 1618
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)
Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Gerrit Holl | last post by:
Hi, would it be a good idea to add a .filter() method to a set object, which behaves like the builtin filter() but resulting in a set? I often see myself doing sets.Set(filter(f, someset))......
9
by: Robin Cull | last post by:
Imagine I have a dict looking something like this: myDict = {"key 1": , "key 2": , "key 3": , "key 4": } That is, a set of keys which have a variable length list of associated values after...
13
by: Peter Mutsaers | last post by:
Hello, Up to now I mostly wrote simple filter scripts in Perl, e.g. while(<>) { # do something with $_, regexp matching, replacements etc. print; } Now I learned Python and like it much...
5
by: Logan | last post by:
I read in PEP 279 the following comment by GvR: "filter and map should die and be subsumed into list comprehensions, not grow more variants." Actually, I am using 'filter' and 'map' a lot in...
3
by: Brian L. | last post by:
After following the discussion on Generator expressions on python-dev for the last few weeks, and finally getting used to list comprehensions as opposed to map/filter, it occurred to me that the...
11
by: Xah Lee | last post by:
© # -*- coding: utf-8 -*- © # Python © © # the "filter" function can be used to © # reduce a list such that unwanted © # elements are removed. © # example: © © def even(n): return n % 2 == 0...
181
by: Tom Anderson | last post by:
Comrades, During our current discussion of the fate of functional constructs in python, someone brought up Guido's bull on the matter: http://www.artima.com/weblogs/viewpost.jsp?thread=98196 ...
4
by: David Pratt | last post by:
Hi. Is anyone aware of any python based unacceptable language filter code to scan and detect bad language in text from uploads etc. Many thanks. David
5
by: thorley | last post by:
Greetings, I'm interested in a simple content-based internet firewall/filter, similar to dansguardian (http://dansguardian.org/), but written in python, and for windows. I assumed such a project...
1
by: kang jia | last post by:
hi i am quite confused between get() function and filter() function, what is the difference between. it seems they all retrieve the specific row from database. i have written this code in one...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.