I'm working on a custom Python script to execute inside 'ExecuteScript' processor in NIFI.
This processor receives input JSON flowfiles and only those that are present in variable filter inside script, should pass through. So the idea is filter JSON based on one column.
My current script looks like this:
import json
flowFile = session.get()
if flowFile is not None:
filter = ['1000007', '1000008']
json_content = json.loads(flowFile.read().decode('utf-8'))
if json_content['Customer_AccountID'] in patata:
filtered_content = json.dumps(json_content)
flowFile.write(bytearray(filtered_content, 'utf-8'))
session.transfer(flowFile, REL_SUCCESS)
else:
session.remove(flowFile)
session.transfer(flowFile, REL_FAILURE)
For now is not filtering anything, no output at all. Any idea why?