0

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.

Sachith Muhandiram
  • 2,819
  • 10
  • 45
  • 94

3 Answers3

1

try to change your regex to be something like

',$'

which means: comma followed by end of line

YuriR
  • 1,251
  • 3
  • 14
  • 26
1

Use replaceEmpty('null') instead of replaceFirst

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

daggett
  • 26,404
  • 3
  • 40
  • 56
1

With processor UpdateRecord you can use

replace( /PROBLEM_COL, '', 'null' )