Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I have a column that contains the mailing address in uppercase: 1234 MAIN WAY DRIVE.
In tMap how would I keep the first character of each word uppercase and lowercase the remaining letters of each word in the string to look like this: 1234 Main Way Drive
Thanks
Hi,
Here is a solution
You need to load the commons-lang-2.6.jar first using tLibraryLoad and to import "org.apache.commons.lang.WordUtils" (go to advanced settings).
And in tMap you make the conversion like this:
That's it!
Hi TRF,
When I load the commons-lang-2.6.jar first using tLibraryLoad and to import "org.apache.commons.lang.WordUtils"
is this a one time load or do I have to do this every time I want to use the WordUtils function in tMap?
2 options:
- tLibraryLoad
- edit routines libraries (could be a good choice to have a routine to transform your strings if you want to do use it in many jobs)
Check this link.
And don't forget to mark your case as solved (kudos also accepted).
I'm trying the second option - edit routines libraries. After creating a new Routine, I click the Edit Routine Libraries, then click the NEW button it asks to "Input a Library's Name". Can you tell me what to type in for the Library's Name?
Thanks
Hi,
Here is a working solution.
1- create your own routine with the following code:
package routines;
import org.apache.commons.lang.WordUtils; public class myRoutine { public static String myCapitalize(String inStr) { return org.apache.commons.lang.WordUtils.capitalizeFully(inStr); } }
Here mine is called "myRoutine".
2- save and close the routine
3- right click the routine then select "Edit Routine Libraries"
4- click "New.." and enter "commons-lang-2.6.jar" as the library's name then enter
5- click Finish
6- change your tMap or (or other component) based on this example:
Congrats, you got now a new routine ready for use from anywhere in your project!
Hi,
I followed your instructions in creating my own routine.
"myroutine" contains the following code
package routines;
import org.apache.commons.lang.WordUtils;
public class myRoutine {
public static String myCapitalize(String inStr) {
return org.apache.commons.lang.WordUtils.capitalizeFully(inStr);
}
}
But next to the line import org.apache.commons.lang.WordUtils; is a little yellow bulb that when you hover over it, it says: "the import org.apache.commons.lang.WordUtils is never used"
Then I changed my tMap as you suggested and it errors saying:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/lang/WordUtils
at dhdproject.step02physicianemailsmatchtonpitest_0_1.Step02PhysicianEmailsMatchToNPITEST.tFileInputDelimited_1Process(Step02PhysicianEmailsMatchToNPITEST.java:7605)
at dhdproject.step02physicianemailsmatchtonpitest_0_1.Step02PhysicianEmailsMatchToNPITEST.tSetGlobalVar_1Process(Step02PhysicianEmailsMatchToNPITEST.java:647)
at dhdproject.step02physicianemailsmatchtonpitest_0_1.Step02PhysicianEmailsMatchToNPITEST.runJobInTOS(Step02PhysicianEmailsMatchToNPITEST.java:10510)
at dhdproject.step02physicianemailsmatchtonpitest_0_1.Step02PhysicianEmailsMatchToNPITEST.main(Step02PhysicianEmailsMatchToNPITEST.java:10289)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.lang.WordUtils
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
[statistics] disconnected
[statistics] disconnected
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 4 more
Job Step02PhysicianEmailsMatchToNPITEST ended at 10:21 22/12/2017. [exit code=1]
Can you help?
Hi TRF,
I tried to create my own routine per your instruction but it failed/error.
Could you see my prior lengthily response to see if we can figure this out?
Thank you!
This does work quite nicely, but not for people's names like McDonald or DeForest. Also it doesn't like my friend Anne-Marie. You get Mcdonald, Deforest and
Anne-marie. I'm sure folks like these are really used to it by now...