0

I have following scenario. In first flowfile, I have :

id,name,sms,call
1,sachith,,07121
2,nalaka,039444,
3,john,04954,
4,malcom,,69595

Then I concatinate sms and call columns together to a new column called operator using UpdateRecord processor. Inspired from this answer

Replacement Value Strategy  Record Path Value
/operator                 concat(/sms, ',', /call)

New flow file is :

id,name,sms,call,operator
1,sachith,,07121,"null,07121"
2,nalaka,039444,,"039444,null"
3,john,04954,,"04954,null"
4,malcom,,69595,"null,,69595"

In next UpdateRecord processor, I try to remove this null and make it into a single value. For that I use (need to modify):

Replacement Value Strategy  Literal Value
/operator                   ${field.value:replaceFirst('null',${field.value:substringBefore(',')})}

Output of this is :

id,name,sms,call,operator
1,sachith,,07121,"null,07121"
2,nalaka,039444,,"039444,039444"
3,john,04954,,"04954,04954"
4,malcom,,69595,"null,69595"

What I want to do is simply remove all these null and replace with the number

id,name,sms,call,operator
1,sachith,,07121,07121
2,nalaka,039444,,039444
3,john,04954,,04954
4,malcom,,69595,69595"

Do I have to use any other processor other than UpdateRecord?

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

1 Answers1

2

Here is the way with UpdateRecord processor which have the options,

Record Reader                 CSVReader
Record Writer                 CSVRecordSetWriter
Replacement Value Strategy    Record Path Value
/operator                     concat(/sms[isEmpty(/call)], /call[isEmpty(/sms)])

This will give you the result as follows:

id,name,sms,call,operator
1,sachith,,07121,07121
2,nalaka,039444,,039444
3,john,04954,,04954
4,malcom,,69595,69595

If both are not null, then they will be concatenated and if both are null, the result will also be null.

Lamanus
  • 12,898
  • 4
  • 21
  • 47