Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello All
I have data in the below format,
Input
FAMILY NURSE CARE , LLC
CANCER CENTER LTD
The output should be in camel casing, every first letter word of string should be in capital and the business extension should be completely capital, i wrote a java code for first letter caps for every word in the string, But now th ask is all the business extenions like LLC, INC should be in Capital letters
required output for above input
Family Nurse Care , LLC
Cancer Center LTD
Can any one give an idea how to achieve this output required
Thanks In Advance
Manish
Hi @ksingh
I believe you are looking for below solution 🙂
The main data is extracted from left most tfileinputdelimited and lookup file contain data like LLC, LTD, CORP etc.
Please note that for fourth line "Comics" is not present in lookup file and it was changed according to normal rule.
tJavarow contain the following code and it will divide the record to two part.
String last = input_row.data.substring(row1.data.lastIndexOf(" ")+1); String first= input_row.data.substring(0, row1.data.lastIndexOf(" ")); // split into words String[] words = first.split(" "); // capitalize each word for (int i = 0; i < words.length; i++) { words[i] = words[i].substring(0, 1).toUpperCase() + words[i].substring(1).toLowerCase(); } // rejoin back into a sentence output_row.first = String.join(" ", words); output_row.last= last.substring(0, 1).toUpperCase() + last.substring(1).toLowerCase();
tMap will do the rest of the magic for you!
Hope you are happy with the results. Request you to please mark the topic as resolved.
Warm Regards,
Nikhil Thampi
Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
Hi @ksingh
If you are sure that all the incoming records will have the last word as LLC, LTD etc. then you can parse the word after last space and convert them to Upper case. All the other words can be made as Initial Cap.
But if you are not sure that last word will not be LLC, LTD etc, then you will have to store the list of these words in a lookup and only for the matches, you can convert to All cap. For all the others, you can convert as Initial Cap.
I believe I had already given solution for Initial Cap for one of your old posts. If you are still facing any issue (you need to do a loop of the incoming data by breaking them to multiple records based on space to check the details), please let me know. I would prefer to use tjavarow to do this task.
Warm Regards,
Nikhil Thampi
Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
thanks @nthampi
yes the last word is not only LLC, LTD . there are nearly 100 words such kind, i started using String replace function but did not worked properly for some cases,
initailly camel case => then used below function but there nearly 100 owrds such kind
Var.trim.toLowerCase().contains (" llc")
?
StringHandling.EREPLACE(Var.trim," Llc"," LLC")
:Var.trim.toLowerCase().contains (" ltd")
?
StringHandling.EREPLACE(Var.trim," Ltd"," LTD")
: Var.trim
Can you please help how to use the lookup model for matches in detail
Thanks In Advance
Manish
Hi @ksingh
I believe you are looking for below solution 🙂
The main data is extracted from left most tfileinputdelimited and lookup file contain data like LLC, LTD, CORP etc.
Please note that for fourth line "Comics" is not present in lookup file and it was changed according to normal rule.
tJavarow contain the following code and it will divide the record to two part.
String last = input_row.data.substring(row1.data.lastIndexOf(" ")+1); String first= input_row.data.substring(0, row1.data.lastIndexOf(" ")); // split into words String[] words = first.split(" "); // capitalize each word for (int i = 0; i < words.length; i++) { words[i] = words[i].substring(0, 1).toUpperCase() + words[i].substring(1).toLowerCase(); } // rejoin back into a sentence output_row.first = String.join(" ", words); output_row.last= last.substring(0, 1).toUpperCase() + last.substring(1).toLowerCase();
tMap will do the rest of the magic for you!
Hope you are happy with the results. Request you to please mark the topic as resolved.
Warm Regards,
Nikhil Thampi
Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
Hi Manish,
If you are happy with the details, could you please mark the topic as resolved?
Warm Regards,
Nikhil Thampi
Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
Thanks @nthampi i tried and it worked, Almost my cases with that kind of format is done but in few strings i have mutliple extensions, like if string name is Manish LLC, INC then the output i got is Manish Llc, INC. but i will try to check the data whether it can be mutliple extensions to one name
Thanks
Manish