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?
Page 1 / 1
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
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.