<?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: How to extract first 5 record from flow file using Nifi Processor? in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-extract-first-5-record-from-flow-file-using-Nifi/m-p/171586#M45856</link>
    <description>&lt;P&gt;Hi &lt;A rel="user" href="https://community.cloudera.com/users/14126/saminathancs17.html" nodeid="14126"&gt;@Saminathan A&lt;/A&gt;&lt;/P&gt;&lt;P&gt;One thing you can do is drop the SplitLine processor and go straight to the ExtractText processor where you can use a regex to pull out the first 5 lines via a regex. Then you can use the groups within that regex to work on the individual groups (e.g., the first 5 lines) in the UpdateAttribute processor. This regex should work for you:  ^(.*)\n(.*)\n(.*)\n(.*)\n(.*)\n.*&lt;/P&gt;</description>
    <pubDate>Fri, 11 Nov 2016 10:44:53 GMT</pubDate>
    <dc:creator>bwilson</dc:creator>
    <dc:date>2016-11-11T10:44:53Z</dc:date>
    <item>
      <title>How to extract first 5 record from flow file using Nifi Processor?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-extract-first-5-record-from-flow-file-using-Nifi/m-p/171585#M45855</link>
      <description>&lt;P&gt;Hi Team,&lt;/P&gt;&lt;P&gt;I have a requirement Where i have to extract first 5 records from a file(Sample.CSV, This file contain 100 rows and 5 column for each row)&lt;/P&gt;&lt;P&gt; 
Out of 5 record, each record of the 2nd column contain value as "Yes" then I want add a ATTRIBUTE for that file "Is_valid=Y" else "Is_valid=N"&lt;/P&gt;&lt;P&gt;Ex: &lt;/P&gt;&lt;P&gt;India,YES,Asia &lt;/P&gt;&lt;P&gt;USA,YES,USA &lt;/P&gt;&lt;P&gt;UK,YES,UK &lt;/P&gt;&lt;P&gt;India1,YES,Asia &lt;/P&gt;&lt;P&gt;USA1,YES,USA&lt;/P&gt;&lt;P&gt;I did following flow, It is working for record level. &lt;/P&gt;&lt;P&gt;GetFile -&amp;gt; Split Line -&amp;gt; Extract Text -&amp;gt; RouteOnAttribte -&amp;gt; UpdateAttribute&lt;/P&gt;&lt;P&gt;But I dont want to do this check for all the record, I need to do this check only for first 5 record and assign the Valid flag for that file. &lt;/P&gt;&lt;P&gt;Please help me on this.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Nov 2016 19:31:32 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-extract-first-5-record-from-flow-file-using-Nifi/m-p/171585#M45855</guid>
      <dc:creator>saminathancs17</dc:creator>
      <dc:date>2016-11-10T19:31:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract first 5 record from flow file using Nifi Processor?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-extract-first-5-record-from-flow-file-using-Nifi/m-p/171586#M45856</link>
      <description>&lt;P&gt;Hi &lt;A rel="user" href="https://community.cloudera.com/users/14126/saminathancs17.html" nodeid="14126"&gt;@Saminathan A&lt;/A&gt;&lt;/P&gt;&lt;P&gt;One thing you can do is drop the SplitLine processor and go straight to the ExtractText processor where you can use a regex to pull out the first 5 lines via a regex. Then you can use the groups within that regex to work on the individual groups (e.g., the first 5 lines) in the UpdateAttribute processor. This regex should work for you:  ^(.*)\n(.*)\n(.*)\n(.*)\n(.*)\n.*&lt;/P&gt;</description>
      <pubDate>Fri, 11 Nov 2016 10:44:53 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-extract-first-5-record-from-flow-file-using-Nifi/m-p/171586#M45856</guid>
      <dc:creator>bwilson</dc:creator>
      <dc:date>2016-11-11T10:44:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract first 5 record from flow file using Nifi Processor?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-extract-first-5-record-from-flow-file-using-Nifi/m-p/171587#M45857</link>
      <description>&lt;P&gt;Thanks &lt;A href="https://community.hortonworks.com/users/99/bwilson.html"&gt;Brandon Wilson&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I tried your suggestion it is working for me. Small correction in regex.&lt;/P&gt;&lt;P&gt;The below one is working for me (Please enable multi-line option in ExtractText configuration )&lt;/P&gt;&lt;P&gt;"regex:  &lt;STRONG&gt;(.*)\n(.*)\n(.*)\n(.*)\n(.*) &lt;/STRONG&gt;" &lt;/P&gt;</description>
      <pubDate>Fri, 11 Nov 2016 13:24:17 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-extract-first-5-record-from-flow-file-using-Nifi/m-p/171587#M45857</guid>
      <dc:creator>saminathancs17</dc:creator>
      <dc:date>2016-11-11T13:24:17Z</dc:date>
    </item>
  </channel>
</rss>

