<?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: Read CSV File with Header and Filter rows and then convert to JSON using Apache Nifi in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/Read-CSV-File-with-Header-and-Filter-rows-and-then-convert/m-p/308117#M223474</link>
    <description>&lt;P&gt;Hello &lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/83993"&gt;@Lokeswar&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The queryRecord processor does exactly what you want. But you need to have your job in a record-oriented approach, using json reader and json writter. Then you don't work with flow-file attribute, but directly with your flow-file content.&lt;/P&gt;&lt;P&gt;So, you have your CSV:&lt;/P&gt;&lt;P&gt;- use a convertRecord to transform it in record flow-file, using CSVreader as reader, and JSONTreeWriter as out writer as you want JSON&lt;/P&gt;&lt;P&gt;- add a queryRecord processor, and your query should look like this: SELECT * FROM FLOWFILE WHERE resourceState='INSTALLED' OR resourceState='RETIRED'&lt;/P&gt;&lt;P&gt;warning: don't use double quote for values, just simple quote&lt;/P&gt;&lt;P&gt;After this, you will have a condition at the output of the queryrecord that you can plugto your next processor.&lt;/P&gt;</description>
    <pubDate>Mon, 21 Dec 2020 10:44:40 GMT</pubDate>
    <dc:creator>stephane_davy</dc:creator>
    <dc:date>2020-12-21T10:44:40Z</dc:date>
    <item>
      <title>Read CSV File with Header and Filter rows and then convert to JSON using Apache Nifi</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Read-CSV-File-with-Header-and-Filter-rows-and-then-convert/m-p/308114#M223473</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Im new to Apache Nifi and i'm looking on how to filter the CSV data using specific column.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;I'm able to convert to JOSN without filtering, but SplitText and RouteonAttribute processors are not helping to filter the data. Below is my input CSV.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Input&lt;/STRONG&gt;:&lt;/P&gt;&lt;P&gt;number,name,resourceState,location,manufacturer&lt;BR /&gt;111897,lok,INSTALLED,HYD,ABC&lt;BR /&gt;115677,redd,RETIRED,BLR,ABC&lt;BR /&gt;1108448,eswar,PROP_INITIAL,CLT,ABC&lt;BR /&gt;1116740,wqwq,INITIAL,AA,ABC&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Filtering should be based on&amp;nbsp;resourceState column to consider INSTALLED and RETIRED data. So, converted JSON should have only 2 rows like below.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Expected JSON Output:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;[{&lt;BR /&gt;"number": "111897",&lt;BR /&gt;"name": "lok",&lt;BR /&gt;"resourceState": "INSTALLED",&lt;BR /&gt;"location": "HYD",&lt;BR /&gt;"manufacturer": "ABC"&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"number": "115677",&lt;BR /&gt;"name": "redd",&lt;BR /&gt;"resourceState": "RETIRED",&lt;BR /&gt;"location": "BLR",&lt;BR /&gt;"manufacturer": "ABC"&lt;BR /&gt;}]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please help me on the CSV filtering part.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in Advance.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Dec 2020 10:34:22 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Read-CSV-File-with-Header-and-Filter-rows-and-then-convert/m-p/308114#M223473</guid>
      <dc:creator>Lokeswar</dc:creator>
      <dc:date>2020-12-21T10:34:22Z</dc:date>
    </item>
    <item>
      <title>Re: Read CSV File with Header and Filter rows and then convert to JSON using Apache Nifi</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Read-CSV-File-with-Header-and-Filter-rows-and-then-convert/m-p/308117#M223474</link>
      <description>&lt;P&gt;Hello &lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/83993"&gt;@Lokeswar&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The queryRecord processor does exactly what you want. But you need to have your job in a record-oriented approach, using json reader and json writter. Then you don't work with flow-file attribute, but directly with your flow-file content.&lt;/P&gt;&lt;P&gt;So, you have your CSV:&lt;/P&gt;&lt;P&gt;- use a convertRecord to transform it in record flow-file, using CSVreader as reader, and JSONTreeWriter as out writer as you want JSON&lt;/P&gt;&lt;P&gt;- add a queryRecord processor, and your query should look like this: SELECT * FROM FLOWFILE WHERE resourceState='INSTALLED' OR resourceState='RETIRED'&lt;/P&gt;&lt;P&gt;warning: don't use double quote for values, just simple quote&lt;/P&gt;&lt;P&gt;After this, you will have a condition at the output of the queryrecord that you can plugto your next processor.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Dec 2020 10:44:40 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Read-CSV-File-with-Header-and-Filter-rows-and-then-convert/m-p/308117#M223474</guid>
      <dc:creator>stephane_davy</dc:creator>
      <dc:date>2020-12-21T10:44:40Z</dc:date>
    </item>
    <item>
      <title>Re: Read CSV File with Header and Filter rows and then convert to JSON using Apache Nifi</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Read-CSV-File-with-Header-and-Filter-rows-and-then-convert/m-p/308143#M223485</link>
      <description>&lt;P&gt;Thanks Stephane,&amp;nbsp;&lt;SPAN&gt;queryRecord processor works as suggested.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Dec 2020 17:44:14 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Read-CSV-File-with-Header-and-Filter-rows-and-then-convert/m-p/308143#M223485</guid>
      <dc:creator>Lokeswar</dc:creator>
      <dc:date>2020-12-21T17:44:14Z</dc:date>
    </item>
  </channel>
</rss>

