2
votes

This question is related to this SO question

Above solution solved my problem, Now I tried to connect this into a flow coming from QueryRecord processor.

Here this QueryRecord divide my flowfile into two streams. Lets say customers and suppliers. And ExecuteGroovyScript is used to add ORDER and COMPLAINT.

Sample csv :

id,record_type
1,0
2,0
3,1

So result should be :

id,record_type
1,ORDER
2,ORDER
3,COMPLAINT

Actual result just placed default 'IGNORE' value.

QueryRecord configurations QueryRecord Configuration

QueryRecord csv write schema. CSV writter

1

1 Answers

3
votes

If you just want to update the field value simply, then use UpdateRecord processor.

When you input the text as follows:

id,record_type
1,0
2,0
3,1

then setting the record reader to CSVReader with the option Schema Access Strategy to the Use String Fields From Header. The writer is not a concern. The UpdateRecord processor properties look like this:

Record Reader               CSVReader
Record Writer               CSVRecordSetWriter
Replacement Value Strategy  Literal Value
/record_type                ${field.value:replace('0','ORDER'):replace('1','COMPLAINT')}

This will give your expected result.