One Star

[resolved] Input has full name field - How to split into FirstName, LastName, etc

My input data has only a FullName field. Is there a tool in to parse the field into separate FirstName, LastName, etc. fields?
The input looks like this: "Firstname Middlename Lastname", where the Middlename can be an initial, a full middle name, a maiden name, or not present. Lastnames can be hyphenated. No prefixes, suffixes, but it would be great to handle those, too.
1 ACCEPTED SOLUTION

Accepted Solutions
Community Manager

Re: [resolved] Input has full name field - How to split into FirstName, LastName, etc

Is there a way to use an if statement in the expression field of tMAP? What would the syntax be?
I want to do something like this for the LastName map expression:
if(StringHandling.LEN(row2.LastName)==0) row2.MiddleInitial
else row2.LastName

Yes, you can use the if...else...statement like this:
StringHandling.LEN(row2.LastName)==0?row2.MiddleInitial : row2.LastName
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
10 REPLIES
One Star

Re: [resolved] Input has full name field - How to split into FirstName, LastName, etc

Just use Java string handling.
One Star

Re: [resolved] Input has full name field - How to split into FirstName, LastName, etc

Can you make a more specific suggestion?
Thanks.
One Star

Re: [resolved] Input has full name field - How to split into FirstName, LastName, etc

See my entry in this post
http://www.talendforge.org/forum/viewtopic.php?id=22880
relating to a function for splitting strings.
One Star

Re: [resolved] Input has full name field - How to split into FirstName, LastName, etc

When I go to that link I get:
Info
Bad request. The link you followed is incorrect or outdated.
Go back
??
One Star

Re: [resolved] Input has full name field - How to split into FirstName, LastName, etc

I've just updated it to a new link.
One Star

Re: [resolved] Input has full name field - How to split into FirstName, LastName, etc

That example didn't apply directly as my input does not have fixed-length fields.
As the FullName components are delimited with <sp> characters, I'm trying tExtractDelimitedFields with some progress.
This works well when there all three name components exist, but puts the LastName in the MiddleName field where there is no MiddleName. I'm trying to use tMap to move the LastName from the MiddleName field to the LastName field in this situation.
Is there a way to use an if statement in the expression field of tMAP? What would the syntax be?
I want to do something like this for the LastName map expression:
if(StringHandling.LEN(row2.LastName)==0) row2.MiddleInitial
else row2.LastName
and for the MiddleInitial map expression:
if(StringHandling.LEN(row2.LastName)!=0) row2.MiddleInitial
What is the correct syntax for this?
Community Manager

Re: [resolved] Input has full name field - How to split into FirstName, LastName, etc

Is there a way to use an if statement in the expression field of tMAP? What would the syntax be?
I want to do something like this for the LastName map expression:
if(StringHandling.LEN(row2.LastName)==0) row2.MiddleInitial
else row2.LastName

Yes, you can use the if...else...statement like this:
StringHandling.LEN(row2.LastName)==0?row2.MiddleInitial : row2.LastName
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: [resolved] Input has full name field - How to split into FirstName, LastName, etc

That example didn't apply directly as my input does not have fixed-length fields.

The code works for variable length text and any delimited text can be extracted.
One Star

Re: [resolved] Input has full name field - How to split into FirstName, LastName, etc

Thanks shong, your suggestion solved my problem!
Is there any tool or technique that can parse a more complex combined-name field (such as: Mr. John J. Jones Jr.) into fine-grained fields (such as Prefix, FN, MN, LN, Suffix)? I'll probably get sources like this in the future.
Community Manager

Re: [resolved] Input has full name field - How to split into FirstName, LastName, etc

Is there any tool or technique that can parse a more complex combined-name field (such as: Mr. John J. Jones Jr.) into fine-grained fields (such as Prefix, FN, MN, LN, Suffix)? I'll probably get sources like this in the future.

There is no a function can handle such kind of combined-name field, if the field is regular, I think you can create a custom routine to parse it, and call the routine in the job.
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business