473,378 Members | 1,134 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,378 software developers and data experts.

Finding one one string in long list of other strings

Using C#/2.0 I'm writing a small "data translator" utility app that reads
data out of a MS Access database and inserts it into a SQL Server database.
The source db lists a bunch of names of people (the particular table
structure is not relevant to this post). We need to identify the gender of
the people as best as we can. We currently have two text files
(MaleNames.txt and FemaleNames.txt) that list typically male or female
names, respectively. So "Scott" would be found in MaleNames.txt and "Julie"
would be found in FemaleNames.txt. There are hundreds of names in each
list/file. Of course some names like "Pat" and "Terry" could easily be
either - so are excluded from this translation process (names migrated, but
no sex specified).

My question:
I'd appreciate some suggestions for matching names with a gender "Male" or
"Female" - and do this matching in the C# utility app.

PCode for the end result I'm after would be something like this:

if (firstName [is in the list of MaleNames])
{
mySqlParm named "Gender" = "Male"
}
else
{
if (firstName [is in the list of FemaleNames])
{
mySqlParm named "Gender" = "Female"
}
else
{
mySqlParm named "Gender" = DBNull.Value
}
}

Thanks!
Sep 13 '06 #1
2 1702
I would put all of the names in a dictionary and just do a lookup to see if
the name exists.

Cheers,

Greg
"Bob Johnson" <A@B.COMwrote in message
news:uN**************@TK2MSFTNGP05.phx.gbl...
Using C#/2.0 I'm writing a small "data translator" utility app that reads
data out of a MS Access database and inserts it into a SQL Server
database. The source db lists a bunch of names of people (the particular
table structure is not relevant to this post). We need to identify the
gender of the people as best as we can. We currently have two text files
(MaleNames.txt and FemaleNames.txt) that list typically male or female
names, respectively. So "Scott" would be found in MaleNames.txt and
"Julie" would be found in FemaleNames.txt. There are hundreds of names in
each list/file. Of course some names like "Pat" and "Terry" could easily
be either - so are excluded from this translation process (names migrated,
but no sex specified).

My question:
I'd appreciate some suggestions for matching names with a gender "Male" or
"Female" - and do this matching in the C# utility app.

PCode for the end result I'm after would be something like this:

if (firstName [is in the list of MaleNames])
{
mySqlParm named "Gender" = "Male"
}
else
{
if (firstName [is in the list of FemaleNames])
{
mySqlParm named "Gender" = "Female"
}
else
{
mySqlParm named "Gender" = DBNull.Value
}
}

Thanks!


Sep 13 '06 #2
Read the textfiles in a string the string = stringMaleList.

if
(stringMaleList..IndexOf("Bob",0,"Bob".length,Stri ngComparison.CurrentCultureIgnoreCase)
-1)
{
//In Malelist
}

"Bob Johnson" <A@B.COMschreef in bericht
news:uN**************@TK2MSFTNGP05.phx.gbl...
Using C#/2.0 I'm writing a small "data translator" utility app that reads
data out of a MS Access database and inserts it into a SQL Server
database. The source db lists a bunch of names of people (the particular
table structure is not relevant to this post). We need to identify the
gender of the people as best as we can. We currently have two text files
(MaleNames.txt and FemaleNames.txt) that list typically male or female
names, respectively. So "Scott" would be found in MaleNames.txt and
"Julie" would be found in FemaleNames.txt. There are hundreds of names in
each list/file. Of course some names like "Pat" and "Terry" could easily
be either - so are excluded from this translation process (names migrated,
but no sex specified).

My question:
I'd appreciate some suggestions for matching names with a gender "Male" or
"Female" - and do this matching in the C# utility app.

PCode for the end result I'm after would be something like this:

if (firstName [is in the list of MaleNames])
{
mySqlParm named "Gender" = "Male"
}
else
{
if (firstName [is in the list of FemaleNames])
{
mySqlParm named "Gender" = "Female"
}
else
{
mySqlParm named "Gender" = DBNull.Value
}
}

Thanks!


Sep 13 '06 #3

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

Similar topics

2
by: Steve | last post by:
Hi, I have a very long string, someting like: DISPLAY=localhost:0.0,FORT_BUFFERED=true, F_ERROPT1=271\,271\,2\,1\,2\,2\,2\,2,G03BASIS=/opt/g03b05/g03/basis,...
13
by: yaipa | last post by:
What would be the common sense way of finding a binary pattern in a ..bin file, say some 200 bytes, and replacing it with an updated pattern of the same length at the same offset? Also, the...
6
by: Joe | last post by:
I have a: vector<string> which contains a few dozen elements. I want to find the index of the element containing a certain string. for example: vector<string> strings;...
2
by: B Moor | last post by:
I have a database with 100,000's records, each with a unique reference, eg A123BNK456 I would like to generate a search facility whereby we can choose an exact match or partial match, where the...
35
by: pinkfloydhomer | last post by:
How do I check if a string contains (can be converted to) an int? I want to do one thing if I am parsing and integer, and another if not. /David
33
by: Jordan Tiona | last post by:
How can I make one of these? I'm trying to get my program to store a string into a variable, but it only stores one line. -- "No eye has seen, no ear has heard, no mind can conceive what God...
17
by: Christoph Scholtes | last post by:
Hi, I have two questions about the following code snippet. I am trying to read in a series of strings and save them to character arrays. Since I dont know how long my string is going to be (and...
1
by: kellysgirl | last post by:
Now what you are going to see posted here is both the set of instructions I was given..and the code I have written. The instructions I was given are as follows In this case, you will create...
275
by: Astley Le Jasper | last post by:
Sorry for the numpty question ... How do you find the reference name of an object? So if i have this bob = modulename.objectname() how do i find that the name is 'bob'
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...

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.