Created 01-14-2016 11:14 PM
I am looking for a simple example of how to use the NiFi ReplaceTextWithMapping to parse file contents. Are templates available including a mapping file? Please share.
Created 01-15-2016 01:14 PM
ReplaceTextWithMapping works exactly like ReplaceText with the exception that the ReplaceText property "Replacement Value" is defined in an external file. Unfortunately the format of that file is not very well documented. I have attached an example of that file and a sample workflow but for a high level overview the mapping file format is newline delimited per mapping defined with a \t character separator the mapping key to the desired replacement value. Good luck and hope this information helps.
Created 01-15-2016 10:50 AM
quick search on the templates github repo shows 0 results. @jpercivall any help?
Created 01-15-2016 01:14 PM
ReplaceTextWithMapping works exactly like ReplaceText with the exception that the ReplaceText property "Replacement Value" is defined in an external file. Unfortunately the format of that file is not very well documented. I have attached an example of that file and a sample workflow but for a high level overview the mapping file format is newline delimited per mapping defined with a \t character separator the mapping key to the desired replacement value. Good luck and hope this information helps.
Created 01-15-2016 05:30 PM
@Jeremy Dyer, thanks again!
This is a good starting point. It seems that the mapping requires a 1-to-1 relationship and might not permit more dynamic programming. I'll continue to research this processor as well as options for ExecuteProcess.
Created 03-31-2016 08:17 PM
Hey Jeremy, just a heads up I just added your template and mapping file to the HWX NiFi Template repo @Artem Ervits mentioned (https://github.com/hortonworks-gallery/nifi-templates)
Created 03-30-2017 05:14 AM
@Jeremy Dyer I understand how a global replacement works, but am struggling when I just want to replace certain occurrences.
Let's say my Flowfile looks like this:
xyz key=AABBBBCC foo bar AABBBBCC
Another one looks like this:
xyz key=DDEEEEFF foo bar DDEEEEFF
I only want to replace the values that are prepended by key=
I tried with Regular Expression key=(\S+) and Matching Group 1 , which didn't work.
What did work was setting the Regex to key=(AABBBBCC|DDEEEEFF), but this unfortunately makes the regex static.