March 30, 2006
Submitted by Matt Castors, Chief of Data Integration, Pentaho
Just wanted to share a Kettle tip with you, this week on the subject of the Script Values step. Let's do ...
The problem is that if you grab the String representation of a field using for example NAME.getString(), you can't use do a replace like in this script:
This will work fine and it will make certain text replace scenarios a lot easier to write.
You too can have access to all the java objects that are in Kettle's classpath. There are a lot of utility libs and you can add your own if you like.
Then you can use all kind of code by specifying the complete name of a class, for example:
If you want to access the complete row that is passing through and not just the individual fields, you can use the row object.
With this you can for example compare the current row with the previous for all kinds of scripting fun...
Someone asked recently: how can I format telephone numbers?
Here is what we could use in Belgium to format telephone numbers, but I guess it can be adapted for other countries as well:
Assuming you have a field called "tel" as input :
For example when the input is 54250137, the output would be 054/250137.
I hope you found this useful. Please feel free to add your own samples below or suggest another topic for next week.