<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question How to use ExecuteScript (with python as a script engine) for an exercise to add numbers? [Novice user trying to learn NiFi] in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/How-to-use-ExecuteScript-with-python-as-a-script-engine-for/m-p/194694#M156754</link>
    <description>&lt;P&gt;I am relatively new to NiFi and am not sure how to do the following correctly. I would like to use &lt;CODE&gt;ExecuteScript&lt;/CODE&gt; processor (script engine: python) to do the following (only in python please):&lt;/P&gt;&lt;P&gt;1) There is a CSV file containing the following information (the first row is the header):&lt;/P&gt;&lt;P&gt;first,second,third&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;1,4,9
7,5,2
3,8,7
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;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:&lt;/P&gt;&lt;P&gt;first,second,third,total&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;1,4,9,14
7,5,2,14
3,8,7,18 &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;For the python script, I wrote:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;def summation(first,second,third):
    numbers = first + second + third
    return numbers
flowFile = session.get()
if (flowFile != None):
    flowFile = session.write(flowFile, summation())
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;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?&lt;/P&gt;&lt;P&gt;The NiFi flow:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="79545-nififlow.png" style="width: 743px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/18068i820FF9D84E621EC3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="79545-nififlow.png" alt="79545-nififlow.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Sun, 18 Aug 2019 06:44:43 GMT</pubDate>
    <dc:creator>annaayub99</dc:creator>
    <dc:date>2019-08-18T06:44:43Z</dc:date>
  </channel>
</rss>

