<?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: Nifi: how to add custom header to CSV file in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Nifi-how-to-add-custom-header-to-CSV-file/m-p/190076#M78196</link>
    <description>&lt;A rel="user" href="https://community.cloudera.com/users/65208/naeemkhan.html" nodeid="65208"&gt;@Naeem Ullah Khan&lt;/A&gt;&lt;P&gt;By using record oriented processors you can&lt;STRONG&gt; ignore the header&lt;/STRONG&gt; in the CSV file and define your own Schema to read the incoming file.&lt;BR /&gt;&lt;STRONG&gt;&lt;U&gt;Example:-&lt;/U&gt;&lt;/STRONG&gt; &lt;/P&gt;&lt;P&gt;Use ConvertRecord processor with&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Record Reader&lt;/STRONG&gt; as &lt;STRONG&gt;CsvReader &lt;/STRONG&gt;and in the csv reader controller service keep the below property values as&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;Treat First Line as Header
&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;true&lt;/PRE&gt;
&lt;/DIV&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;Ignore CSV Header Column Names
&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;true&lt;/PRE&gt;&lt;/DIV&gt;&lt;P&gt;With this property values we are treating the first line as header and ignoring the header column names.&lt;/P&gt;&lt;P&gt;Define your Avro schema for the incoming CSV file, by using this setting you are able to parse the incoming file.&lt;/P&gt;&lt;P&gt;In &lt;STRONG&gt;Record Reader&lt;/STRONG&gt; as &lt;STRONG&gt;CSVSetWriter&lt;/STRONG&gt; and refer the same avro schema registry for writer also(if you need all the columns needed in the output flowfile).&lt;/P&gt;&lt;P&gt;Keep the below property to true&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;Include Header Line&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;true&lt;/PRE&gt;&lt;P&gt;Each Csv file will get new header matching with the avro schema.&lt;/P&gt;&lt;P&gt;Refer to &lt;A href="https://community.hortonworks.com/articles/115311/convert-csv-to-json-avro-xml-using-convertrecord-p.html" target="_blank"&gt;this&lt;/A&gt; link how to configure Convert Record processor and there are bunch of other articles regarding configurations of record oriented processors.&lt;/P&gt;</description>
    <pubDate>Fri, 11 May 2018 19:13:10 GMT</pubDate>
    <dc:creator>Shu_ashu</dc:creator>
    <dc:date>2018-05-11T19:13:10Z</dc:date>
    <item>
      <title>Nifi: how to add custom header to CSV file</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Nifi-how-to-add-custom-header-to-CSV-file/m-p/190074#M78194</link>
      <description>&lt;P&gt;I am working to clean CSV files and stuck due to additional coma's in headers. Can any body guide me how to replace header line with customer header.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Sep 2022 13:12:50 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Nifi-how-to-add-custom-header-to-CSV-file/m-p/190074#M78194</guid>
      <dc:creator>naeem_khan</dc:creator>
      <dc:date>2022-09-16T13:12:50Z</dc:date>
    </item>
    <item>
      <title>Re: Nifi: how to add custom header to CSV file</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Nifi-how-to-add-custom-header-to-CSV-file/m-p/190075#M78195</link>
      <description>&lt;A rel="user" href="https://community.cloudera.com/users/65208/naeemkhan.html" nodeid="65208" target="_blank"&gt;@Naeem Ullah Khan&lt;/A&gt;&lt;P&gt;You can use Replace text processor with &lt;B&gt;Replacement Strategy &lt;/B&gt; as prepend and keep your custom header in Replacement value property value. if your file size more than 1 MB then you need to change the Maximum Buffer Size according to your flow file size.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="72764-replacetext.png" style="width: 2033px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/18530i8A5077C2CBA0DCB1/image-size/medium?v=v2&amp;amp;px=400" role="button" title="72764-replacetext.png" alt="72764-replacetext.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;With this configs each flowfile will have custom header line added as first line of the flowfile and all the content will be added from second line.&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;P&gt;If the Answer helped to resolve your issue, &lt;STRONG&gt;Click on Accept button below to accept the answer,&lt;/STRONG&gt; That would be great help to Community users to find solution quickly for these kind of issues.&lt;/P&gt;</description>
      <pubDate>Sun, 18 Aug 2019 07:39:36 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Nifi-how-to-add-custom-header-to-CSV-file/m-p/190075#M78195</guid>
      <dc:creator>Shu_ashu</dc:creator>
      <dc:date>2019-08-18T07:39:36Z</dc:date>
    </item>
    <item>
      <title>Re: Nifi: how to add custom header to CSV file</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Nifi-how-to-add-custom-header-to-CSV-file/m-p/190076#M78196</link>
      <description>&lt;A rel="user" href="https://community.cloudera.com/users/65208/naeemkhan.html" nodeid="65208"&gt;@Naeem Ullah Khan&lt;/A&gt;&lt;P&gt;By using record oriented processors you can&lt;STRONG&gt; ignore the header&lt;/STRONG&gt; in the CSV file and define your own Schema to read the incoming file.&lt;BR /&gt;&lt;STRONG&gt;&lt;U&gt;Example:-&lt;/U&gt;&lt;/STRONG&gt; &lt;/P&gt;&lt;P&gt;Use ConvertRecord processor with&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Record Reader&lt;/STRONG&gt; as &lt;STRONG&gt;CsvReader &lt;/STRONG&gt;and in the csv reader controller service keep the below property values as&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;Treat First Line as Header
&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;true&lt;/PRE&gt;
&lt;/DIV&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;Ignore CSV Header Column Names
&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;true&lt;/PRE&gt;&lt;/DIV&gt;&lt;P&gt;With this property values we are treating the first line as header and ignoring the header column names.&lt;/P&gt;&lt;P&gt;Define your Avro schema for the incoming CSV file, by using this setting you are able to parse the incoming file.&lt;/P&gt;&lt;P&gt;In &lt;STRONG&gt;Record Reader&lt;/STRONG&gt; as &lt;STRONG&gt;CSVSetWriter&lt;/STRONG&gt; and refer the same avro schema registry for writer also(if you need all the columns needed in the output flowfile).&lt;/P&gt;&lt;P&gt;Keep the below property to true&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;Include Header Line&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;true&lt;/PRE&gt;&lt;P&gt;Each Csv file will get new header matching with the avro schema.&lt;/P&gt;&lt;P&gt;Refer to &lt;A href="https://community.hortonworks.com/articles/115311/convert-csv-to-json-avro-xml-using-convertrecord-p.html" target="_blank"&gt;this&lt;/A&gt; link how to configure Convert Record processor and there are bunch of other articles regarding configurations of record oriented processors.&lt;/P&gt;</description>
      <pubDate>Fri, 11 May 2018 19:13:10 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Nifi-how-to-add-custom-header-to-CSV-file/m-p/190076#M78196</guid>
      <dc:creator>Shu_ashu</dc:creator>
      <dc:date>2018-05-11T19:13:10Z</dc:date>
    </item>
    <item>
      <title>Re: Nifi: how to add custom header to CSV file</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Nifi-how-to-add-custom-header-to-CSV-file/m-p/190077#M78197</link>
      <description>&lt;P&gt;Dear &lt;A rel="user" href="https://community.cloudera.com/users/18929/yaswanthmuppireddy.html" nodeid="18929"&gt;@Shu&lt;/A&gt; it worked perfectly, concept was simple but great, thank you !!&lt;/P&gt;</description>
      <pubDate>Mon, 14 May 2018 18:23:45 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Nifi-how-to-add-custom-header-to-CSV-file/m-p/190077#M78197</guid>
      <dc:creator>naeem_khan</dc:creator>
      <dc:date>2018-05-14T18:23:45Z</dc:date>
    </item>
  </channel>
</rss>

