I have one column for marital status having value:
and now i want,
married for M
single for S
Divorce for D
Solved! Go to Solution.
Use ternary operator.. Below is logic like: (Add null check , if the Marital status column is nullable )
Note: I assumed the datatype for the column MaritalStatus is character so i used equality operator, if the MaritalStatus is string use equals method(String handling )..
i tried that but its not workin, i have attached the screenshot of the function and the output of that.
Are you sure about your Source Data ?
it's "M" or "M " or "m"
you have to trim your data before, and i think there is a function like equalsIgnoreCase, or something like that.
Edit : Other thing : i see that your data is entoured by this character : '
Take Care ! You have to define in your tFileInputDelimited (Check CSV option), the entourage of your text. I think your String value must be like : "'M'" instead of "M"
Looks like you're happy using Java code for this, but the tReplace component is often a much better choice for such things:
By default you don't need to worry about case sensitivity, but can enable it for each search/replace line if required, and it keeps the logic for your job visible, rather than hidden within more general components. It also has an advanced mode which allows the use of Regular Expressions, which are incredibly powerful should you need them.
Whenever possible, you should use components with specific functionality like this, rather than adding complex expressions in a tMap or code in a tJava component, as doing so means your job is largely self documenting, or at least much easier for someone new picking it up to read and understand the process you're automating. Good, well laid out and labelled jobs can also be useful when discussing things with non-technical people.