Created on 07-20-2018 05:06 PM - edited 08-17-2019 11:44 PM
I am relatively new to NiFi and am not sure how to do the following correctly. I would like to use
ExecuteScript processor (script engine: python) to do the following (only in python please):
1) There is a CSV file containing the following information (the first row is the header):
1,4,9 7,5,2 3,8,7
2) I would like to find the sum of individual rows and generate a final file with a modified header. The final file should look like this:
1,4,9,14 7,5,2,14 3,8,7,18
For the python script, I wrote:
def summation(first,second,third): numbers = first + second + third return numbers flowFile = session.get() if (flowFile != None): flowFile = session.write(flowFile, summation())
But it does not work and I am not sure how to fix this. Can anyone provide me an understanding on how to approach this problem?
The NiFi flow:
First, congrats on getting started with NiFi and not being afraid to tackle one of the harder processors: ExecuteScript.
My advice is to start small, get a working script that maybe doesnt do what you want, but does actually complete and return SUCCESS in your NiFi flow. From there you can start building it up and testing step by step. I also recommend that you tail the NIFI Log during all of your work so that you can see any errors or information from each test/step. My last peice of advice for an advanced script would be to manually execute your script to ensure that its logic is working outside of the execution from within NiFi.
You may find the following links very helpful:
If my answer is helpful, please choose ACCEPT.