firstname,middle name, lastname
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 32
- Joined: Tue Dec 20, 2011 8:03 am
firstname,middle name, lastname
Hi
my source is teradata and target is sequential file.
source data:
vekat raJU
VENKAT RAM Raju narayana
output:
firstname=venkat
secondname=raju
middle name=null
firstname=venkat
secondname=ramraju
middle name=narayana.
based on the delimeter(space) I have to divide into three parts. Some times middle name contains two spaces.
my code:
sv1---> field(col1,' ',1)---firstname.
sv2--->field(col1,' ',dcount(col1,' '))--> lastname
can you please let us know how to get middle name?
my source is teradata and target is sequential file.
source data:
vekat raJU
VENKAT RAM Raju narayana
output:
firstname=venkat
secondname=raju
middle name=null
firstname=venkat
secondname=ramraju
middle name=narayana.
based on the delimeter(space) I have to divide into three parts. Some times middle name contains two spaces.
my code:
sv1---> field(col1,' ',1)---firstname.
sv2--->field(col1,' ',dcount(col1,' '))--> lastname
can you please let us know how to get middle name?
-
- Participant
- Posts: 32
- Joined: Tue Dec 20, 2011 8:03 am
Try this solution with 2 stage variables:
svWorkString Trim(In.NameString)
svNumberOfSpaces dcount(svWorkString)
Out.FirstName = Field(svWorkString,' ',1)
Out.LastName = Field(svWorkString,' ',svNumberOfSpaces)
Out.MiddleNames = Field(svWorkstring,' ',2,svNumberOfSpaces-2)
If there are no middle name(s) the Out.MiddleNames will be empty. The code above makes no provisions for strings with just one name.
svWorkString Trim(In.NameString)
svNumberOfSpaces dcount(svWorkString)
Out.FirstName = Field(svWorkString,' ',1)
Out.LastName = Field(svWorkString,' ',svNumberOfSpaces)
Out.MiddleNames = Field(svWorkstring,' ',2,svNumberOfSpaces-2)
If there are no middle name(s) the Out.MiddleNames will be empty. The code above makes no provisions for strings with just one name.
<a href=http://www.worldcommunitygrid.org/team/ ... TZ9H4CGVP1 target="WCGWin">
</a>
</a>
Hi srivalli_b,
In the above scenario the compactwhitespace function should work fine....If there are multiple spaces in first name,lastname can you plese let me know how to handle this.
Code: Select all
If Dcount(CompactWhiteSpace(Col1)," ") >2 Then Field(CompactWhiteSpace(Col1)," ",2,Dcount(CompactWhiteSpace(Col1)," ")-2) Else ""
-
- Participant
- Posts: 32
- Joined: Tue Dec 20, 2011 8:03 am
Thanks for your reply.
multiple spaces will occur either first name,last name,middle name.some times multiple spaces may be occur at a time in middle and first,last names.
I think your code will work where I will know particular names (middle or last or first) will occur multiple spaces.
Please help me
multiple spaces will occur either first name,last name,middle name.some times multiple spaces may be occur at a time in middle and first,last names.
I think your code will work where I will know particular names (middle or last or first) will occur multiple spaces.
Please help me
I did answer the question, with my code the input "William Jefferson 'Bill' Clinton"
Would get separated into First name "Wiliam", last name "Clinton", middle name "Jefferson 'Bill'".
Would get separated into First name "Wiliam", last name "Clinton", middle name "Jefferson 'Bill'".
<a href=http://www.worldcommunitygrid.org/team/ ... TZ9H4CGVP1 target="WCGWin">
</a>
</a>
Hi Srivalli_b,
I have tried with the below input-
Please confirm whether the above occurances of spaces between the strings are same as you are getting.If not please specify.
I have tried with the below input-
Code: Select all
vekat raJU
VENKAT RAM Raju narayana
Jean Claude Van Damme
Code: Select all
Field(CompactWhiteSpace(src.col1)," ",1) col1
If Dcount(CompactWhiteSpace(src.col1)," ") >2 Then Field(CompactWhiteSpace(src.col1)," ",2,Dcount(CompactWhiteSpace(src.col1)," ")-2) Else "" col2
Field(CompactWhiteSpace(src.col1)," ", Dcount(CompactWhiteSpace(src.col1)," ")) col3
People provided code because your original problem definition was finite - one word first name, one word last name with only the 'middle name' possible as multiple words.srivalli_b wrote:multiple spaces will occur either first name,last name,middle name.some times multiple spaces may be occur at a time in middle and first,last names.
If that is not the case, meaning any of the three 'pieces' could be multiple words (contain spaces) then there is no simple parsing solution. It requires intelligence to recognize what bits look like first names, which look like last names and which remaining bits must be the middle name... never mind all of the Mr/Mrs/Dr/Jr/Sr bits. You are now firmly in the territory that companies (including IBM) build and market expensive software applications to solve.
In my opinion, the best you could do is go back to your original position but knowing that it will be wrong at times and probably require manual intervention to correct.
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers