Hi,
I want to add headers to a csv file. I have used Replace text processor for this purpose.
But final output just append headers to the first line.
eg:
Sample :
2-Dec-15,Mumbai,120
Expected output :
date,city,temp 2-Dec-15,Mumbai,120
Output :
date,city,temp2-Dec-15,Mumbai,120
I have tried both ways by adding '\n' and 'shift+enter' after the header line
id,name,site,score\n
id,name,site,scoreshift+enter as the replacement value,
but no luck instead \n and shift+enter was taken as a value.
Could anyone help to resolve this issue.
Created 12-17-2019 07:04 AM
I am not sure why this is not working for you.
I built a test flow and it is working fine for me.
Here is how I have my ReplaceText processor component configured:
I also used "shift+enter" to create a new line at the end of the header being inserted (note that a blank line "2" is shown) and the "Prepend" replacement strategy.
I passed it the following test CSV content:
15-Dec-19,Baltimore,27
17-Dec-19,Baltimore,34
I then listed the queue on the success relationship connection outbound from the ReplaceText processor. From there I could click on "View Details" icon to far left of my FlowFile in the queue list and then click "VIEW' to see what the resulting content looked like.
Here is what I see for my sample source content above:
I am using Apache NiFi 1.9
Hope this helps,
Matt
Created 12-17-2019 07:04 AM
I am not sure why this is not working for you.
I built a test flow and it is working fine for me.
Here is how I have my ReplaceText processor component configured:
I also used "shift+enter" to create a new line at the end of the header being inserted (note that a blank line "2" is shown) and the "Prepend" replacement strategy.
I passed it the following test CSV content:
15-Dec-19,Baltimore,27
17-Dec-19,Baltimore,34
I then listed the queue on the success relationship connection outbound from the ReplaceText processor. From there I could click on "View Details" icon to far left of my FlowFile in the queue list and then click "VIEW' to see what the resulting content looked like.
Here is what I see for my sample source content above:
I am using Apache NiFi 1.9
Hope this helps,
Matt
Created 12-17-2019 08:51 PM
Thanks Matt for the quick response.