Thursday 17 December 2009

Left padding of string field in Kettle

I had to left pad a field using Kettle. It was a postal code mistakenly coded as a double in an Access database and it had to be transformed. In my country, postal codes consist of 5 digits, the first of which could be "0".

Mapping the field to "string" was not good enough: blanks were used for padding. In order to use "0", I had to use the JavaScript node in Kettle. The following graphic contains my little code snippet:

For some reason, the code did not "validate" in the node (there is a "validation" button), but the data flow worked as a charm.

No comments:

Post a Comment