Search code examples
replaceapache-nifinifi-processor

Replace column values using Apache NiFi


I have a sample csv looks like this

ID,FNAME,PROBLEM_COL
1,sachith,
2,nalaka,
3,john,
4,adams,

Always PROBLEM_COL value is empty. I want to replace empty with null string.

For that I used UpdateRecord processor and CSVReader with Use String Fields From Headers
Custom value as /PROBLEM_COL and ${field.value:replaceFirst('','null')}

This runs without error/warning. But PROBLEM_COL is not replaced. I had referred this, but this does not solve my issue. My headers are in block-letters.


Solution

  • Use replaceEmpty('null') instead of replaceFirst

    https://nifi.apache.org/docs/nifi-docs/html/expression-language-guide.html#replaceempty