pythonapache-nifiprocessors

How to Trim and Update Attribute values for NiFi?


I want to trim all of the whitespace leading and/or tailing the subject.

NiFi Processors being used:

  1. Get File
  2. Extract Text
  3. Update Attribute --The issue lies here
  4. AttributestoJSON
  5. ConvertJSONtoSQL
  6. PutSQL
  7. PutFile

Mock Email:

Body of Email fake data obviously

Student: Troy Bolton

Classification: Junior

ID: 880647

DOB: 8/26/1995

SSN: 218-54-6321

School: Harvard

Note: Apartment, No Roommate

End Body of Email

When I use the Regex function trim() for NiFi it does not trim the leading or tailing whitespace from its subject.

Question: Using the above, how would I correctly achieve this using the UpdateAttribute processor??

Let me know if you need more clarification.


Solution

  • in the UpdateAttribute processor, if the property name is Student but the property name in the ExtractText is Student-1 and the attribute you are looking for is Student then you would

    ${Student-1:substringAfter('Student: '):trim()}