Support Questions
Find answers, ask questions, and share your expertise

How to add a default value for a csv

Explorer

I am trying to add a default value to a csv if its empty in given file.

 

My flow is GetFile → UpdateAttributes → PutFile

 

My CSV

id,name,age

1,sachith,29

2,,17

 

In my 'UpdateAttribute'

I have added a property called 'name' and ${name:replaceNull("abc")}

 

But its not updating the record. I can see the same record in my result folder.

 

Do I have to use a separate processor for this?

 

Thanks in advance.

 

2 REPLIES 2

Contributor

Hi @sachith ,

 

Use QueryRecord processor and configure/enable Reader/Writer controller services

Add custom sql query as new property to the processor

 

QueryRecord configs:

select id,age,
    CASE WHEN name='' THEN 'abc'
    end name
from FLowfile

 

The output flowfile from QueryRecord processor will have your desired result

id,name,age
1,sachith,29
2,abc,17

 

Best,

Helmi KHALIFA

Explorer

Unfortunately it doesn't.

 

My result CSV looks like this

 

id,age,name
1,29,
2,17,

Take a Tour of the Community
Don't have an account?
Your experience may be limited. Sign in to explore more.