Split Name Field
-
All - I am looking for an easy solution to split a name field from another DB. I am converting data from on DB to another. In the source DB the name field is one field that is free form. Here are some examples of names: John Smith John E Smith DR John E Smith DR John Smith In my db the name field is first and last name (separate fields). Any suggestions? As always thanks for your help! sk
-
All - I am looking for an easy solution to split a name field from another DB. I am converting data from on DB to another. In the source DB the name field is one field that is free form. Here are some examples of names: John Smith John E Smith DR John E Smith DR John Smith In my db the name field is first and last name (separate fields). Any suggestions? As always thanks for your help! sk
-
All - I am looking for an easy solution to split a name field from another DB. I am converting data from on DB to another. In the source DB the name field is one field that is free form. Here are some examples of names: John Smith John E Smith DR John E Smith DR John Smith In my db the name field is first and last name (separate fields). Any suggestions? As always thanks for your help! sk
Its a tricky one because you have a number of possibilities, i.e. Title and middle names. If this was a one of process I would use manual intervention, but would also have fields for title. Do you want to retain the title anywhere? where should the middle name be included? I would put the middle name with the forename if I only had two fields (forename, surname) Why don't you try something like...
void GetMeSomeNames(string fullname, out string forename, out string surname)
{
forename = surname = "";
string[] names = fullname.Split(' ', StringFormatOptions.RemoveEmptyEntries);
if(names.length == 0)
return;
if(names.length == 1)
{
forename = names[0];//or surname if preferred
return;
}bool hasTitle = false;
switch(names[0].ToLowerInvarient())
{
case "dr":
hasTitle = true;
case "mr":
hasTitle = true;
//etc...
}
for(int i = (hasTitle ? 1 : 0); i < names.length - 1; i++)
forename += names[i] + " ";
forename = forename.Trim();
surname = names[names.length-1];
}Life goes very fast. Tomorrow, today is already yesterday.
-
All - I am looking for an easy solution to split a name field from another DB. I am converting data from on DB to another. In the source DB the name field is one field that is free form. Here are some examples of names: John Smith John E Smith DR John E Smith DR John Smith In my db the name field is first and last name (separate fields). Any suggestions? As always thanks for your help! sk
Essentially, it is a tough task. There may be names that just have a first and last or first, middle and last and it may contains salutations (Dr, Mr, Mrs, etc.) also. Writing a script to take care of all of these scenarios is really difficult. Just give it a try.
-
All - I am looking for an easy solution to split a name field from another DB. I am converting data from on DB to another. In the source DB the name field is one field that is free form. Here are some examples of names: John Smith John E Smith DR John E Smith DR John Smith In my db the name field is first and last name (separate fields). Any suggestions? As always thanks for your help! sk
You need some sort of agreement on what is considered first name and what is considered last name. You could also have the following eg: John Smith Peeters John Edward Smith John Edward Smith Peeters John Edward Smith-Peeters John E. Smith-Peeters ... You could filter Dr, DR, Mr, Ms, ... as a title and one letter words (with or without . like E or E.) can be considered firstnames, but I'm not sure if it's possible to have a 100% correct algorithm. good luck.
V.
Stop smoking so you can: Enjoy longer the money you save. Moviereview Archive -
All - I am looking for an easy solution to split a name field from another DB. I am converting data from on DB to another. In the source DB the name field is one field that is free form. Here are some examples of names: John Smith John E Smith DR John E Smith DR John Smith In my db the name field is first and last name (separate fields). Any suggestions? As always thanks for your help! sk
I don't think it can be done without human intervention. At best you could put the last element in the last name field and everything else in the first name field. Then review any first names that contain a SPACE.
-
I don't think it can be done without human intervention. At best you could put the last element in the last name field and everything else in the first name field. Then review any first names that contain a SPACE.
PIEBALDconsult wrote:
At best you could put the last element in the last name field and everything else in the first name field.
That would yield a lot of problems where I live, as: 1) a lot of last names consist of two or three words, such as "Miel De Schepper" and "Jan van der Spiegel" (first names are Miel/Jan); here you should at least check for "de", "van der" and "van de" (all possible capitalizations) and when they occur they are part of the last name. 2) first names could be composite ("Jean-Paulus") and last names could be composite ("Paulus-Beeldens"); now what when one of them is composite, the hyphen is missing, and the middle word of three could be a second half of the first name, or the first half of the last name (say "Jean Paulus Beeldens")? I am 100% sure there isn't an algorithm that solves the problem, and IMO the best fit algorithm is very region dependent. :)
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages