Hi all!
I create a database that contains a table. 'Nachname' is one of 13
column names. This program can search for
a special letter. In my example it is 'ra'. and the search takes place
in 'Nachname'. 'ra' takes place within a word. This is solved with
regular expression. So that I can limit my search.
For example: I can search for 'ra' and it is not relevant wich letters
follow or wich letters are in front of 'ra'.
Now I want to abstract the column name 'Nachname'. So I search in an
unknown column. Only the user of the program should determine in wich
class the search takes place. This input should happen in the view
lines of testing the class.
My task is it to change the program that a abstraction of the column
names takes place.
Please give me a detailed answer. If it is possible the changed
program because I am very new in Python and I am orientationless .
This is the program
import sys
import Mk4py
import re
db = Mk4py.storage(" c:\\datafile.mk ",1)
vw = db.view("people ")
class PatternFilter:
def __init__(self, pattern):
self.pattern = re.compile(patt ern)
def __call__(self, row):
try:
nachname = row.Nachname
except AttributeError:
return 0
return self.pattern.se arch(nachname)i s not None
vf = vw.filter(Patte rnFilter("ra.*" ))
for r in vf:
print vw[r.index].Nachname 4 2145
Wiebke Pätzold <wi************ *@mplusr.de> wrote in message news:<h2******* *************** **********@4ax. com>... Hi all!
I create a database that contains a table. 'Nachname' is one of 13 column names. This program can search for a special letter. In my example it is 'ra'. and the search takes place in 'Nachname'. 'ra' takes place within a word. This is solved with regular expression. So that I can limit my search. For example: I can search for 'ra' and it is not relevant wich letters follow or wich letters are in front of 'ra'. Now I want to abstract the column name 'Nachname'. So I search in an unknown column. Only the user of the program should determine in wich class the search takes place. This input should happen in the view lines of testing the class. My task is it to change the program that a abstraction of the column names takes place. Please give me a detailed answer. If it is possible the changed program because I am very new in Python and I am orientationless .
This is the program
import sys import Mk4py import re
db = Mk4py.storage(" c:\\datafile.mk ",1) vw = db.view("people ")
class PatternFilter: def __init__(self, pattern): self.pattern = re.compile(patt ern)
def __call__(self, row): try: nachname = row.Nachname except AttributeError: return 0 return self.pattern.se arch(nachname)i s not None
vf = vw.filter(Patte rnFilter("ra.*" ))
for r in vf: print vw[r.index].Nachname
RegEx are really great and there are a lot of problems you can
only solve with them. But if I understand you right your problem
is to find a string where a substring is to be in, the simple
string operation does the work:
if String.find(sub string) > -1:
**find** will give you the position in String where substring
will occure the 1rst time and -1 if substring doesn't occur.
e.g. nameList=['Meyer', 'Maxon', 'Johnson', 'Mueller'] for name in nameList:
.... if name.find('er') >-1:
.... print name
....
Meyer
Mueller
So if you can get your columns contents in **ColumnList**
and your searchpattern in **SearchPattern ** so the following
function could do the work:
def getPatternMatch es(ColumnList,S earchPattern):
foundList=[]
for n in ColumnList:
if n.find(SearchPa ttern) > -1:
foundList.appen d(n)
return foundList
Regards
Peter
On 5 Aug 2003 14:00:23 -0700, p-****@t-online.de (Peter Abel) wrote: Wiebke Pätzold <wi************ *@mplusr.de> wrote in message news:<h2******* *************** **********@4ax. com>... Hi all!
I create a database that contains a table. 'Nachname' is one of 13 column names. This program can search for a special letter. In my example it is 'ra'. and the search takes place in 'Nachname'. 'ra' takes place within a word. This is solved with regular expression. So that I can limit my search. For example: I can search for 'ra' and it is not relevant wich letters follow or wich letters are in front of 'ra'. Now I want to abstract the column name 'Nachname'. So I search in an unknown column. Only the user of the program should determine in wich class the search takes place. This input should happen in the view lines of testing the class. My task is it to change the program that a abstraction of the column names takes place. Please give me a detailed answer. If it is possible the changed program because I am very new in Python and I am orientationless .
This is the program
import sys import Mk4py import re
db = Mk4py.storage(" c:\\datafile.mk ",1) vw = db.view("people ")
class PatternFilter: def __init__(self, pattern): self.pattern = re.compile(patt ern)
def __call__(self, row): try: nachname = row.Nachname except AttributeError: return 0 return self.pattern.se arch(nachname)i s not None
vf = vw.filter(Patte rnFilter("ra.*" ))
for r in vf: print vw[r.index].Nachname
RegEx are really great and there are a lot of problems you can only solve with them. But if I understand you right your problem is to find a string where a substring is to be in, the simple string operation does the work: if String.find(sub string) > -1:
**find** will give you the position in String where substring will occure the 1rst time and -1 if substring doesn't occur.
e.g. nameList=['Meyer', 'Maxon', 'Johnson', 'Mueller'] for name in nameList:... if name.find('er') >-1: ... print name ... Meyer Mueller
So if you can get your columns contents in **ColumnList** and your searchpattern in **SearchPattern ** so the following function could do the work:
def getPatternMatch es(ColumnList,S earchPattern): foundList=[] for n in ColumnList: if n.find(SearchPa ttern) > -1: foundList.appen d(n) return foundList
Regards Peter
I think you didn't understand me. My task is:
I have a database that consists of a tabla with different columns. The
program should have two possibilities to search for regular
expressions. The firat one possibility is in this program. Here I can
look for a certain expression. In my example I can look for 'ra' and
it is not relevant wich letters follow or wich letters are in front of
'ra'. But this search can ONLY takes place in the column 'Nachname'.
'Nachname is fixed by the programmer.
The second possibility is that the user and NOT the programmer
determine the column name in which the user want to look for a regular
expression. And so I think there must be anything with a print. Only
like that the user can enterin what column the search takes place.
On 5 Aug 2003 14:00:23 -0700, p-****@t-online.de (Peter Abel) wrote: Wiebke Pätzold <wi************ *@mplusr.de> wrote in message news:<h2******* *************** **********@4ax. com>... Hi all!
I create a database that contains a table. 'Nachname' is one of 13 column names. This program can search for a special letter. In my example it is 'ra'. and the search takes place in 'Nachname'. 'ra' takes place within a word. This is solved with regular expression. So that I can limit my search. For example: I can search for 'ra' and it is not relevant wich letters follow or wich letters are in front of 'ra'. Now I want to abstract the column name 'Nachname'. So I search in an unknown column. Only the user of the program should determine in wich class the search takes place. This input should happen in the view lines of testing the class. My task is it to change the program that a abstraction of the column names takes place. Please give me a detailed answer. If it is possible the changed program because I am very new in Python and I am orientationless .
This is the program
import sys import Mk4py import re
db = Mk4py.storage(" c:\\datafile.mk ",1) vw = db.view("people ")
class PatternFilter: def __init__(self, pattern): self.pattern = re.compile(patt ern)
def __call__(self, row): try: nachname = row.Nachname except AttributeError: return 0 return self.pattern.se arch(nachname)i s not None
vf = vw.filter(Patte rnFilter("ra.*" ))
for r in vf: print vw[r.index].Nachname
RegEx are really great and there are a lot of problems you can only solve with them. But if I understand you right your problem is to find a string where a substring is to be in, the simple string operation does the work: if String.find(sub string) > -1:
**find** will give you the position in String where substring will occure the 1rst time and -1 if substring doesn't occur.
e.g. nameList=['Meyer', 'Maxon', 'Johnson', 'Mueller'] for name in nameList:... if name.find('er') >-1: ... print name ... Meyer Mueller
So if you can get your columns contents in **ColumnList** and your searchpattern in **SearchPattern ** so the following function could do the work:
def getPatternMatch es(ColumnList,S earchPattern): foundList=[] for n in ColumnList: if n.find(SearchPa ttern) > -1: foundList.appen d(n) return foundList
Regards Peter
I forgot something:
The user must have the choice between a special search in a concrete
split and a search in all columns. The user have to determine wich
search method is used.
On 5 Aug 2003 14:00:23 -0700, p-****@t-online.de (Peter Abel) wrote: Wiebke Pätzold <wi************ *@mplusr.de> wrote in message news:<h2******* *************** **********@4ax. com>... Hi all!
I create a database that contains a table. 'Nachname' is one of 13 column names. This program can search for a special letter. In my example it is 'ra'. and the search takes place in 'Nachname'. 'ra' takes place within a word. This is solved with regular expression. So that I can limit my search. For example: I can search for 'ra' and it is not relevant wich letters follow or wich letters are in front of 'ra'. Now I want to abstract the column name 'Nachname'. So I search in an unknown column. Only the user of the program should determine in wich class the search takes place. This input should happen in the view lines of testing the class. My task is it to change the program that a abstraction of the column names takes place. Please give me a detailed answer. If it is possible the changed program because I am very new in Python and I am orientationless .
This is the program
import sys import Mk4py import re
db = Mk4py.storage(" c:\\datafile.mk ",1) vw = db.view("people ")
class PatternFilter: def __init__(self, pattern): self.pattern = re.compile(patt ern)
def __call__(self, row): try: nachname = row.Nachname except AttributeError: return 0 return self.pattern.se arch(nachname)i s not None
vf = vw.filter(Patte rnFilter("ra.*" ))
for r in vf: print vw[r.index].Nachname
RegEx are really great and there are a lot of problems you can only solve with them. But if I understand you right your problem is to find a string where a substring is to be in, the simple string operation does the work: if String.find(sub string) > -1:
**find** will give you the position in String where substring will occure the 1rst time and -1 if substring doesn't occur.
e.g. nameList=['Meyer', 'Maxon', 'Johnson', 'Mueller'] for name in nameList:... if name.find('er') >-1: ... print name ... Meyer Mueller
So if you can get your columns contents in **ColumnList** and your searchpattern in **SearchPattern ** so the following function could do the work:
def getPatternMatch es(ColumnList,S earchPattern): foundList=[] for n in ColumnList: if n.find(SearchPa ttern) > -1: foundList.appen d(n) return foundList
Regards Peter
there is another problem too. I have NOT a string. Ihave a TABLE. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Ruby Tuesday |
last post by:
Which one is better to do dynamic websites using MySQL? Thanks
a.. ADODB, http://php.weblogs.com/ADOdb/
b.. Metabase, http://www.phpclasses.org/browse.html/package/20.html
c.. PEAR::DB, http://pear.php.net/manual/en/core.db.php
d.. PHPLib database wrappers, http://sourceforge.net/projects/phplib
|
by: Rainer Collet |
last post by:
hi!
i tested several php database abstraction layers (db, mdb(2), creole,
adodb, etc), but i always missed one really important feature:
i need a method for a limited select which gives me the resultset and
the total number of rows the select would have returned without the
limit.
nativly this is very easy
SELECT SQL_CALC_FOUND ROWS * FROM table LIMIT 0,10 in mysql for
example.
|
by: Joe |
last post by:
Hi All,
I am new to using the Access DB and I need some help if someone
is able to give it to me. What I want to do is get the names of
the columns of certain tables. Not the data in the table but the
table column names.
I've seen other posts that suggest using the SQL command DESCRIBE
but I can't get it to work for some reason. Other posts have code
samples but they're written in VB which I am not familiar with. I
|
by: Showjumper |
last post by:
Is it possible to retrieve a table name and then all the column names in
that table from an access database? And then once that is done, then build a
sql insert statement using the retrieved table and columns names?
Thanks
Ashok
|
by: Colin McKinnon |
last post by:
Hi all,
There's lots of DB abstraction layers out there, but a quick look around
them hasn't turned up anything which seems to met my requirements. Before I
go off and write one I thought I'd ask here if anyone knows of such a
beast...
I want some code where I present an array of data, and the corresponding
primary key and let the code work out whether to INSERT or UPDATE it, I
also want to be able to present the data from a QBF or...
| |
by: Arthur Pemberton |
last post by:
What is the best way to do data source abtraction? For example have
different classes with the same interface, but different
implementations.
I was thinking of almost having classA as my main class, and have
classA dynamically "absorb" classFood into to based on the extension
of the input file received by classA. But this doesn't seem possible.
Please advise.
|
by: TamusJRoyce |
last post by:
Hello. This is my first thread here.
My problem has probably been came across by a lot of people, but tutorials and things I've seen don't address it (usually too basic).
My problem is that I would like to use Abstraction for a "plug-in" like interface to classes.
class ThreadHandle
{
/* stuff here not yet dealing with threads */
|
by: s0suk3 |
last post by:
I'm developing a project which I'm trying to keep as organized as
possible. Since C doesn't support classes, I've been trying to make do
mostly with structs and functions that operate on them. However,
sometimes some of the "higher-level" modules contain functions that
map more or less directly to functions calls in "lower-level" modules.
So I've been having trouble naming these such functions, since ideally
both of them (the one in the...
|
by: Big Daddy |
last post by:
For example, if I have a DB table called DownloadPoints with a column
named DownloadPointNo, then SqlMetal will create a file with a class
called DownloadPoints with an accessor named DownloadPointNo. I would
like the object to be able to pass me the string "DownloadPointNo".
For example, the code could be something like:
DownloadPoints dp = new DownloadPoints();
string colName = dp.DownloadPointNo.ColumnName;
Or I could write a...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |