I’m trying to build a graph to cleanse some datalogging files which are the result of collecting data from temperature sensors. Sometimes there’s a hiccup in the collection and we get a null value from the sensor. In this case, we want to replace the null with the value from the previous record. How can I do this within Clover, please?
Hi Bob,
There is few options how you can remember data of previous records while passing through transformation components, e.g. Reformat:
-
store previous values in dictionary - http://doc.cloveretl.com/documentation/ … -ctl2.html
-
define “global” variable which can hold data during whole transformation run
//#CTL2
integer lastValue;
function integer transform() {
//current value not null
if ($in.0.value!=null) {
//send to output
$out.0.value = $in.0.value;
//update last non-null value
lastValue = $in.0.value;
} else {
//use last non-null value for output
$out.0.value = lastValue;
}
return ALL;
}
For both approaches you may use map/list datatype, see http://doc.cloveretl.com/documentation/ … -ctl2.html for details.