How to Trim and Update Attribute values for NiFi?

Question:

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.

Asked By: PickleRick

||

Answers:

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()}

Answered By: PickleRick
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.