Support Questions
Find answers, ask questions, and share your expertise

Python script in Nifi, Put attribute to flowFIie issue

New Contributor

Using Execute Script Processor to do a simple task

  1. Get 2 lists from incoming flow file attribute
  2. Generate new list based on above attributes 
  3. Place new list to new attribute of the flow file

as session.putattribute() needs string input, casted list to String as well. But new attribute is bit weird. When ran all python stuff in python compiler, result is as expected. But while using putattribute it becoming weird.


flowFile = session.get( )
if (flowFile != None):
    n_f_l = flowFile.getAttribute('n_f_l')
    d_f_l = flowFile.getAttribute('d_f_l')
    m_f = set(n_f_l)
    if len(n_f_l) != len(d_f_l):
        for i in set(n_f_l):
            if i in d_f_l:
    m_f_2 = ',\n '.join([str(n) for n in m_f])
    flowFile = session.putAttribute(flowFile,'n_m_f',m_f_2)
    session.transfer(flowFile, REL_SUCCESS)



Expected Result:



Output result:


K, 0, 4