How to split a field with comma separated values

One Star

How to split a field with comma separated values

I have a csv file that I need to transform and export out a NEW csv file.
My current path is:
tFileInputDelimited_1 --> tMap_1 --> tBufferOutput_1 --> tFileOutputDelimited_1

The column, "Full Name" has "Last Name, First Name" in one string and i need to extract both names and place them into two different columns.
Is there a TRIM function i am missing that will allow me to trim from the comma in the string?
Employee

Re: How to split a field with comma separated values

Hi davidag1,
Maybe a look at the tExtractRegexFields component will give you a clue.
For instance : http://www.talendforge.org/forum/viewtopic.php?pid=14503
PS : Your tBufferOutput is maybe not mandatory in this kind of job
Regards,
Cyril
One Star

Re: How to split a field with comma separated values

Column Name: Full_Name
e.g. Full_Name = Gonzalez, David
I am trying to use the tExtractRegexFields with the following command
^(?<LastName>\w+),\s?(?<FirstName>\w+)$

Which works with in Regex Builder but not in tExtractRegexFields -- it complains "Invalid escape sequence (valid ones are \b \t \n \f \r \" \' \\)
Any ideas?
Six Stars

Re: How to split a field with comma separated values

Avoid the regex for such simple split... just use tExtractdelimfields to generate two field out of one....
One Star

Re: How to split a field with comma separated values

thx emaxt6
I got the job to work with the following:
tFileInputDelimited_1 --> tExtractDelimitedFields_1 --> tMap_1 --> tFileOutputDelimited_1
Seven Stars

Re: How to split a field with comma separated values

Re your problem with tExtractRegexFields: remember that \ is an escape character for Java and regex so to use a regex shorthand character class such as \w in Talend (Java), you need \\w.
One Star

Re: How to split a field with comma separated values

Thank you alevy!