Support Questions
Find answers, ask questions, and share your expertise
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Append Text in each line of FlowFile content in NiFi

Append Text in each line of FlowFile content in NiFi

New Contributor

Hello Everyone,

I have a use case to append text at the end of each line from a new file or new table. ReplaceText processor helps me in appending fixed text in each line of flowfile content but the text should be appended from second file. I cannot use MergeContent processor I do not need a union merge but as below explained -

Example :

First File : employeeID, employeeName, employeeSalary

1, John, $100

2, Kevin, $150

3, Steve, $200

Second File : employeeID, department, location.

1, Finance, CA

2, Technology, NY

3, Teaching, VA

Output : employeeID, employeeName, employeeSalary,department, location.

1, John, $100,Finance, CA

2, Kevin, $150,Technology, NY

3, Steve, $200,Teaching, VA

Best Regards


Re: Append Text in each line of FlowFile content in NiFi

If your second file is a single file with a static location, you could set up a flow that just gets that file (ListFile -> FetchFile) and stores the values (with employee ID as a key and the rest as value) into a DistributedMapCache. Run that flow first before starting the second flow, which could send your "First File" above into a Split Text (to process each line) then a FetchDistributedMapCache, which will populate values from the lookup table as attributes, then a ReplaceText to get the attribute values appended to the line, then a MergeContent to put it all back together.

Alternatively if you're comfortable with a scripting language you can use ExecuteScript or InvokeScriptedProcessor. The approach might be similar to this post.

Don't have an account?
Coming from Hortonworks? Activate your account here