<?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 Remove first few lines in a text/csv flowfile content in Apache NiFi in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/Remove-first-few-lines-in-a-text-csv-flowfile-content-in/m-p/379383#M243850</link>
    <description>&lt;P&gt;I receive a text/csv file with many lines through an InvokeHttp Processor. My requirement is that I don't want the first 7 lines. What should I do to remove the first 7 lines and keep the remaining the same text/csv format.&lt;/P&gt;</description>
    <pubDate>Wed, 22 Nov 2023 09:06:48 GMT</pubDate>
    <dc:creator>glad1</dc:creator>
    <dc:date>2023-11-22T09:06:48Z</dc:date>
    <item>
      <title>Remove first few lines in a text/csv flowfile content in Apache NiFi</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Remove-first-few-lines-in-a-text-csv-flowfile-content-in/m-p/379383#M243850</link>
      <description>&lt;P&gt;I receive a text/csv file with many lines through an InvokeHttp Processor. My requirement is that I don't want the first 7 lines. What should I do to remove the first 7 lines and keep the remaining the same text/csv format.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Nov 2023 09:06:48 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Remove-first-few-lines-in-a-text-csv-flowfile-content-in/m-p/379383#M243850</guid>
      <dc:creator>glad1</dc:creator>
      <dc:date>2023-11-22T09:06:48Z</dc:date>
    </item>
    <item>
      <title>Re: Remove first few lines in a text/csv flowfile content in Apache NiFi</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Remove-first-few-lines-in-a-text-csv-flowfile-content-in/m-p/379417#M243859</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/103587"&gt;@glad1&lt;/a&gt; ,&lt;/P&gt;&lt;P&gt;Can you elaborate more on the data that you want to remove? For example if the data is part of the CSV and it has unique value in one or more columns, then you can use QueryRecord processor where the query exclude records with this unique value. If the data is out of the CSV - like a header information - then depending how this data look like and if its surrounded with some special characters then you can use ReplaceText Processor with regex that would isolate those lines and then replace them with empty space and so on. If you can provide some sample data it would help in figuring out the best solution for this scenario.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 22 Nov 2023 17:23:00 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Remove-first-few-lines-in-a-text-csv-flowfile-content-in/m-p/379417#M243859</guid>
      <dc:creator>SAMSAL</dc:creator>
      <dc:date>2023-11-22T17:23:00Z</dc:date>
    </item>
    <item>
      <title>Re: Remove first few lines in a text/csv flowfile content in Apache NiFi</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Remove-first-few-lines-in-a-text-csv-flowfile-content-in/m-p/379423#M243861</link>
      <description>&lt;P&gt;I you're confident the data returned is consistent and always more than 7 lines...then a quick and dirty would be a Groovy script like this.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="java"&gt;import java.nio.charset.StandardCharsets

FlowFile flowFile = session.get()
if(!flowFile) return

flowFile = session.write(flowFile, {inputStream, outputStream -&amp;gt;
                                      String[] data = inputStream.readLines()
                                      data = data.drop(7)
                                      outputStream.write(data.join("\n").getBytes(StandardCharsets.UTF_8))
                                  } as StreamCallback)
session.transfer(flowFile, REL_SUCCESS)&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 22 Nov 2023 19:33:36 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Remove-first-few-lines-in-a-text-csv-flowfile-content-in/m-p/379423#M243861</guid>
      <dc:creator>joseomjr</dc:creator>
      <dc:date>2023-11-22T19:33:36Z</dc:date>
    </item>
    <item>
      <title>Re: Remove first few lines in a text/csv flowfile content in Apache NiFi</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Remove-first-few-lines-in-a-text-csv-flowfile-content-in/m-p/379442#M243863</link>
      <description>&lt;P&gt;Thank you, this worked!&lt;/P&gt;</description>
      <pubDate>Thu, 23 Nov 2023 05:49:47 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Remove-first-few-lines-in-a-text-csv-flowfile-content-in/m-p/379442#M243863</guid>
      <dc:creator>glad1</dc:creator>
      <dc:date>2023-11-23T05:49:47Z</dc:date>
    </item>
    <item>
      <title>Re: Remove first few lines in a text/csv flowfile content in Apache NiFi</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Remove-first-few-lines-in-a-text-csv-flowfile-content-in/m-p/379444#M243864</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="glad1_0-1700718465953.png" style="width: 700px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/38990i5B152D6C3F2DDBDC/image-dimensions/700x116?v=v2" width="700" height="116" role="button" title="glad1_0-1700718465953.png" alt="glad1_0-1700718465953.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;^ I've attached the image above. this is how the data looks. I want to clean the first 7 rows and let the 8th row (header row) be first.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Nov 2023 05:52:57 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Remove-first-few-lines-in-a-text-csv-flowfile-content-in/m-p/379444#M243864</guid>
      <dc:creator>glad1</dc:creator>
      <dc:date>2023-11-23T05:52:57Z</dc:date>
    </item>
  </channel>
</rss>

