Ask Your Question
1

How can I access each record field and its value in Jython?

asked 2019-01-30 13:41:12 -0500

iamontheinet gravatar image

updated 2019-01-30 14:00:14 -0500

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

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2019-01-30 13:43:24 -0500

iamontheinet gravatar image

updated 2019-01-30 14:30:08 -0500

You can use the following Jython code to iterate through each record (field,value) pair:

for record in records:
  try:
    # Access each record field and its value    
    for (field,val) in record.value.iteritems():
      log.info("*** field: {} | value: {}",field,val)

      #do something... 

    # Write record to processor output
    output.write(record)

  except Exception as e:
    # Send record to error
    error.write(record, str(e))

Cheers, Dash

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2019-01-30 13:41:12 -0500

Seen: 375 times

Last updated: Jan 30