Today, i will discuss about the split fields component usage based on the occurrence of delimiter. In last blog, we encountered that if occurrence of delimiter vary, then the split field component will not work effectively. In other words, alone split field component is sufficient to get the proper results.

Please see the below image which demonstrate the dynamically using split field component based on the count of delimiter occurrence.

Here, switch/case component and java expression is added. Below is the java script used to get the occurrence of delimiter.

var cnt = getOcuranceString(Var1,’;’)

The above expression will give the count based of delimiter occurrence. For example, the value of Var1 is a;b;c , then value of cnt is 2.If the value of Var1 is a;b, then the value of cnt is 1. So, based on cnt value, switch/case component route the request to respective split field component.

Run the transformation with Var1 as a;b;c;d. Below lines will appear on the Pentaho logs.

Write to log 2.0 – ————> Linenr 1——————————
Write to log 2.0 – var11 = a
Write to log 2.0 – var12 = b
Write to log 2.0 – var13 = c
Write to log 2.0 – var14 = d
Write to log 2.0 – cnt = 3

Run the transformation with Var1 as a;b. Below lines will appear on the Pentaho logs.

Write to log.0 – ————> Linenr 1——————————
Write to log.0 – var11 = a
Write to log.0 – var12 = b
Write to log.0 – cnt = 1

So, based on value of delimiter count, split field component can be used.  See the below image regarding switch/case values.

Related posts