Skip to main content

I am using Groovy Evaluator processor in my Data Collector pipeline and I would like programmatic access to each record field and its values in a loop. How can I achieve that?

You can use the following Groovy code to iterate through each record’s field,value pairs:

for (record in records) {
try {
// Access each record field and its value
for ( record_dict in record.value ) {
record_key = record_dict.key
record_value = record.valuelrecord_key]
sdc.log.info(">>> field: {} | value: {}",record_key,record_value)

// do something meaningful...
}
output.write(record)
} catch (e) {
error.write(record, e.toString())
}
}

Cheers,

Dash


Reply