Skip to content

Instantly share code, notes, and snippets.

@jdye64
Created April 22, 2018 18:53
Show Gist options
  • Save jdye64/73cd14907228a83dff3d9a3629c4b129 to your computer and use it in GitHub Desktop.
Save jdye64/73cd14907228a83dff3d9a3629c4b129 to your computer and use it in GitHub Desktop.
import codecs
def onTrigger(context, session):
flow_file = session.get()
if flow_file is not None:
log.info('got flow file: %s' % flow_file.getAttribute('filename'))
filename = flow_file.getAttribute('filename')
counter = filename.split('_')[1].split('.')[0]
log.info('counter is: %s' % counter)
weight_file = open('/tmp/weight/weight_' + counter + '.txt')
weight = weight_file.read()
weight_file.close()
log.info('Weight is: %s' % weight)
flow_file.addAttribute("weight", weight)
session.transfer(flow_file, REL_SUCCESS) 1,1 All
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment