<?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 Re: manipulate flowfile with executescript processor in nifi with python in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/manipulate-flowfile-with-executescript-processor-in-nifi/m-p/213760#M175684</link>
    <description>&lt;P&gt;Hi, &lt;/P&gt;&lt;P&gt;Have you been able to make it work? Could you please share your script here?&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
    <pubDate>Tue, 28 Nov 2017 09:34:28 GMT</pubDate>
    <dc:creator>skhaksho</dc:creator>
    <dc:date>2017-11-28T09:34:28Z</dc:date>
    <item>
      <title>manipulate flowfile with executescript processor in nifi with python</title>
      <link>https://community.cloudera.com/t5/Support-Questions/manipulate-flowfile-with-executescript-processor-in-nifi/m-p/213758#M175682</link>
      <description>&lt;P&gt;Hello, &lt;/P&gt;&lt;P&gt;I want to do some stuff on my data while ingesting so i created a little python script to do that . &lt;/P&gt;&lt;P&gt;I am ingesting csv files and want to remove carriage return, linefeed etc in the columns. Also adding new column with timestamp&lt;/P&gt;&lt;P&gt;My script looks lige this&lt;/P&gt;&lt;PRE&gt;import csv
import sys  
flowFile = session.get()                 
 with open(flowFile, 'rb') as csvfile:
        spamreader = csv.reader(csvfile, delimiter='    ', quotechar='|')
        for row in spamreader:
                for col in row:
                        col.rstrip('\n\r ')


                print ', '.join(row)


&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="14890-executescript1.png" style="width: 1680px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/16481iB448590B84693B43/image-size/medium?v=v2&amp;amp;px=400" role="button" title="14890-executescript1.png" alt="14890-executescript1.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Right now i got this error when running it&lt;/P&gt;&lt;PRE&gt;2017-04-27 12:40:13,463 ERROR [Timer-Driven Process Thread-8] o.a.nifi.processors.script.ExecuteScript ExecuteScript[id=af58777c-015b-1000-ffff-ffff972978f8] Failed to process session due to org.apache.nifi.processor.exception.ProcessException: javax.script.ScriptException: NameError: name 'flowfile' is not defined in &amp;lt;script&amp;gt; at line number 3: org.apache.nifi.processor.exception.ProcessException: javax.script.ScriptException: NameError: name 'flowfile' is not defined in &amp;lt;script&amp;gt; at line number 3


&lt;/PRE&gt;&lt;P&gt;What should i add to this script in order to output the manipulated flowfiles to the next process. Do i need to rewrite them like&lt;/P&gt;&lt;P&gt;session.write(flowfile). &lt;/P&gt;&lt;P&gt;I am not a python programmer so please be kind and supply small example   &lt;/P&gt;&lt;P&gt;Thank you &lt;/P&gt;</description>
      <pubDate>Sun, 18 Aug 2019 03:37:15 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/manipulate-flowfile-with-executescript-processor-in-nifi/m-p/213758#M175682</guid>
      <dc:creator>simon_jespersen</dc:creator>
      <dc:date>2019-08-18T03:37:15Z</dc:date>
    </item>
    <item>
      <title>Re: manipulate flowfile with executescript processor in nifi with python</title>
      <link>https://community.cloudera.com/t5/Support-Questions/manipulate-flowfile-with-executescript-processor-in-nifi/m-p/213759#M175683</link>
      <description>&lt;A rel="user" href="https://community.cloudera.com/users/16412/simonjespersen.html" nodeid="16412"&gt;@Simon Jespersen&lt;/A&gt;&lt;P&gt;Does the script have to be written using Python?   There is a three part article written by &lt;A rel="user" href="https://community.cloudera.com/users/641/mburgess.html" nodeid="641"&gt;@Matt Burgess&lt;/A&gt; that has some great examples: &lt;A href="https://community.hortonworks.com/articles/75032/executescript-cookbook-part-1.html"&gt;ExecuteScript Cookbook&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 29 Apr 2017 00:38:30 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/manipulate-flowfile-with-executescript-processor-in-nifi/m-p/213759#M175683</guid>
      <dc:creator>Wynner</dc:creator>
      <dc:date>2017-04-29T00:38:30Z</dc:date>
    </item>
    <item>
      <title>Re: manipulate flowfile with executescript processor in nifi with python</title>
      <link>https://community.cloudera.com/t5/Support-Questions/manipulate-flowfile-with-executescript-processor-in-nifi/m-p/213760#M175684</link>
      <description>&lt;P&gt;Hi, &lt;/P&gt;&lt;P&gt;Have you been able to make it work? Could you please share your script here?&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 28 Nov 2017 09:34:28 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/manipulate-flowfile-with-executescript-processor-in-nifi/m-p/213760#M175684</guid>
      <dc:creator>skhaksho</dc:creator>
      <dc:date>2017-11-28T09:34:28Z</dc:date>
    </item>
    <item>
      <title>Re: manipulate flowfile with executescript processor in nifi with python</title>
      <link>https://community.cloudera.com/t5/Support-Questions/manipulate-flowfile-with-executescript-processor-in-nifi/m-p/213761#M175685</link>
      <description>&lt;P&gt;I found that the replacetext processor could do this for me with a very little effort. So i did not use executeScript for this. &lt;/P&gt;</description>
      <pubDate>Tue, 28 Nov 2017 18:32:21 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/manipulate-flowfile-with-executescript-processor-in-nifi/m-p/213761#M175685</guid>
      <dc:creator>simon_jespersen</dc:creator>
      <dc:date>2017-11-28T18:32:21Z</dc:date>
    </item>
    <item>
      <title>Re: manipulate flowfile with executescript processor in nifi with python</title>
      <link>https://community.cloudera.com/t5/Support-Questions/manipulate-flowfile-with-executescript-processor-in-nifi/m-p/213762#M175686</link>
      <description>&lt;P&gt;Looks like it might just have been a typo between "flowFile" and "flowfile"&lt;/P&gt;</description>
      <pubDate>Wed, 29 Nov 2017 02:53:15 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/manipulate-flowfile-with-executescript-processor-in-nifi/m-p/213762#M175686</guid>
      <dc:creator>mburgess</dc:creator>
      <dc:date>2017-11-29T02:53:15Z</dc:date>
    </item>
  </channel>
</rss>

