The header of my csv file contains some special character. Example
And I want to use the processor Replace Text to edit only the header. When I use the Append Stratesy for the entire text, it dosen't work.
Help plz. Thank you
You can use a regular expression to isolate the header line (for example search the entire content, start at the beginning using "^", and stop on the first newline) and replace it with what you'd like to have. You'l have to test out different regex strings to see what works for you but this should get you started.
Please take a look at the following HCC thread:
That thread also links to this website, which you can use to create your expressions and directly copy them to NiFi. You may not be using the correct syntax if it isn't working, so please verify with this website:
As suggested by @anarasimham With Start of the string(^) in Replace text processor should match only the first line.
Make sure you are having matching regex that exclude special character.
in the above configs i'm matching only the first line in the flowfile and adding new to the first line only and all the other contents will be untouched.
You can use one of the way that i have suggested in this link, please refer to the shared link and choose the method that will best fit for your case.
If you are still having issues please share some sample data with header and the expected output?
@Shu Thank you for your response when I tried this regex expression :
It changed only the first occurance of a special character.
I have in input this csv file :
I expect an output file like this one:
Use one of the way from the above shared link to take out only the header from the csv file then in replace text keep the
then search for (&|\(|\)|\/_|\s) and in Replacement value keep as empty string, now we are searching for all the special characters in the header flowfile then replacing with empty string.Now add this header flowfile with the other non header flowfile. all the explanation and template.xml are shared in this link.