<?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: please suggest me steps,how i can insert csv file(in local system) into  database table. i have configured GetFile and PutSql processor but i am getting issue to configured replace text processor. in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/please-suggest-me-steps-how-i-can-insert-csv-file-in-local/m-p/228914#M61045</link>
    <description>&lt;P&gt;As of NiFi 1.2.0, after GetFile you can use the &lt;A target="_blank" href="https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi/nifi-standard-nar/1.2.0/org.apache.nifi.processors.standard.PutDatabaseRecord/index.html"&gt;PutDatabaseRecord&lt;/A&gt; processor with a &lt;A target="_blank" href="https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi/nifi-record-serialization-services-nar/1.2.0/org.apache.nifi.csv.CSVReader/index.html"&gt;CSVReader&lt;/A&gt;, giving it a schema if you know the layout, or if the CSV file has a header row you can get the column names from that using "Use String Fields From Header" for the Schema Access Strategy property.&lt;/P&gt;&lt;P&gt;Prior to NiFi 1.2.0, after GetFile you probably want a SplitText to get each row in its own flow file. Do you know the number of columns for the CSV file? If so then you can use a regex in &lt;A target="_blank" href="https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi/nifi-standard-nar/1.2.0/org.apache.nifi.processors.standard.ExtractText/index.html"&gt;ExtractText&lt;/A&gt;; assuming there were four columns you might have a dynamic property called "column" set to something like:&lt;/P&gt;&lt;PRE&gt;([^,]+),([^,]+),([^,]+),([^,]+)&lt;/PRE&gt;&lt;P&gt;That should give you attributes "column.1", "column.2", "column.3", and "column.4". Then you can use ReplaceText to generate a SQL statement, perhaps something like:&lt;/P&gt;&lt;PRE&gt;INSERT INTO myTable VALUES(${column.1},${column.2},${column.3},${column.4})&lt;/PRE&gt;&lt;P&gt;Then send that to PutSQL.  Another option (prior to NiFi 1.2.0) is to convert the CSV to Avro (see &lt;A target="_blank" href="https://community.hortonworks.com/articles/28341/converting-csv-to-avro-with-apache-nifi.html"&gt;this HCC article&lt;/A&gt;), then &lt;A target="_blank" href="https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi/nifi-avro-nar/1.2.0/org.apache.nifi.processors.avro.ConvertAvroToJSON/index.html"&gt;ConvertAvroToJSON&lt;/A&gt;, then &lt;A target="_blank" href="https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi/nifi-standard-nar/1.2.0/org.apache.nifi.processors.standard.ConvertJSONToSQL/index.html"&gt;ConvertJSONToSQL&lt;/A&gt;, then PutSQL. &lt;/P&gt;</description>
    <pubDate>Sat, 13 May 2017 09:33:04 GMT</pubDate>
    <dc:creator>mburgess</dc:creator>
    <dc:date>2017-05-13T09:33:04Z</dc:date>
    <item>
      <title>please suggest me steps,how i can insert csv file(in local system) into  database table. i have configured GetFile and PutSql processor but i am getting issue to configured replace text processor.</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/please-suggest-me-steps-how-i-can-insert-csv-file-in-local/m-p/228913#M61044</link>
      <description />
      <pubDate>Fri, 12 May 2017 14:32:37 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/please-suggest-me-steps-how-i-can-insert-csv-file-in-local/m-p/228913#M61044</guid>
      <dc:creator>santosh_hencha</dc:creator>
      <dc:date>2017-05-12T14:32:37Z</dc:date>
    </item>
    <item>
      <title>Re: please suggest me steps,how i can insert csv file(in local system) into  database table. i have configured GetFile and PutSql processor but i am getting issue to configured replace text processor.</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/please-suggest-me-steps-how-i-can-insert-csv-file-in-local/m-p/228914#M61045</link>
      <description>&lt;P&gt;As of NiFi 1.2.0, after GetFile you can use the &lt;A target="_blank" href="https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi/nifi-standard-nar/1.2.0/org.apache.nifi.processors.standard.PutDatabaseRecord/index.html"&gt;PutDatabaseRecord&lt;/A&gt; processor with a &lt;A target="_blank" href="https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi/nifi-record-serialization-services-nar/1.2.0/org.apache.nifi.csv.CSVReader/index.html"&gt;CSVReader&lt;/A&gt;, giving it a schema if you know the layout, or if the CSV file has a header row you can get the column names from that using "Use String Fields From Header" for the Schema Access Strategy property.&lt;/P&gt;&lt;P&gt;Prior to NiFi 1.2.0, after GetFile you probably want a SplitText to get each row in its own flow file. Do you know the number of columns for the CSV file? If so then you can use a regex in &lt;A target="_blank" href="https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi/nifi-standard-nar/1.2.0/org.apache.nifi.processors.standard.ExtractText/index.html"&gt;ExtractText&lt;/A&gt;; assuming there were four columns you might have a dynamic property called "column" set to something like:&lt;/P&gt;&lt;PRE&gt;([^,]+),([^,]+),([^,]+),([^,]+)&lt;/PRE&gt;&lt;P&gt;That should give you attributes "column.1", "column.2", "column.3", and "column.4". Then you can use ReplaceText to generate a SQL statement, perhaps something like:&lt;/P&gt;&lt;PRE&gt;INSERT INTO myTable VALUES(${column.1},${column.2},${column.3},${column.4})&lt;/PRE&gt;&lt;P&gt;Then send that to PutSQL.  Another option (prior to NiFi 1.2.0) is to convert the CSV to Avro (see &lt;A target="_blank" href="https://community.hortonworks.com/articles/28341/converting-csv-to-avro-with-apache-nifi.html"&gt;this HCC article&lt;/A&gt;), then &lt;A target="_blank" href="https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi/nifi-avro-nar/1.2.0/org.apache.nifi.processors.avro.ConvertAvroToJSON/index.html"&gt;ConvertAvroToJSON&lt;/A&gt;, then &lt;A target="_blank" href="https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi/nifi-standard-nar/1.2.0/org.apache.nifi.processors.standard.ConvertJSONToSQL/index.html"&gt;ConvertJSONToSQL&lt;/A&gt;, then PutSQL. &lt;/P&gt;</description>
      <pubDate>Sat, 13 May 2017 09:33:04 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/please-suggest-me-steps-how-i-can-insert-csv-file-in-local/m-p/228914#M61045</guid>
      <dc:creator>mburgess</dc:creator>
      <dc:date>2017-05-13T09:33:04Z</dc:date>
    </item>
    <item>
      <title>Re: please suggest me steps,how i can insert csv file(in local system) into  database table. i have configured GetFile and PutSql processor but i am getting issue to configured replace text processor.</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/please-suggest-me-steps-how-i-can-insert-csv-file-in-local/m-p/228915#M61046</link>
      <description>&lt;P&gt;thanks for response...&lt;/P&gt;&lt;P&gt; i have hard coded in replacetext processor (for testing purpose)  such as:  insert into table_name (ID) values ('2')   and in putsql processor i am getting same insert statement(in data provenance input claim view). and same table  table_name i have create in data base but i am not getting any error and it's not going to insert.. connection  with data base table is fine(no issue).. &lt;/P&gt;&lt;P&gt;flow is getfile&amp;gt;&amp;gt;replacetext&amp;gt;&amp;gt;putsql.&lt;/P&gt;</description>
      <pubDate>Sat, 13 May 2017 22:29:48 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/please-suggest-me-steps-how-i-can-insert-csv-file-in-local/m-p/228915#M61046</guid>
      <dc:creator>santosh_hencha</dc:creator>
      <dc:date>2017-05-13T22:29:48Z</dc:date>
    </item>
    <item>
      <title>Re: please suggest me steps,how i can insert csv file(in local system) into  database table. i have configured GetFile and PutSql processor but i am getting issue to configured replace text processor.</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/please-suggest-me-steps-how-i-can-insert-csv-file-in-local/m-p/279669#M61047</link>
      <description>Moved because this question differed significantly from the original thread and the original question was marked 'solved' in May 2017.</description>
      <pubDate>Tue, 08 Oct 2019 10:25:26 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/please-suggest-me-steps-how-i-can-insert-csv-file-in-local/m-p/279669#M61047</guid>
      <dc:creator>ask_bill_brooks</dc:creator>
      <dc:date>2019-10-08T10:25:26Z</dc:date>
    </item>
  </channel>
</rss>

