<?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 replace value in file in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/how-to-replace-value-in-file/m-p/334544#M231806</link>
    <description>&lt;P&gt;thank you advice , I use you design, but i get the result like this, it has two row header:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;test_a|test_b|test_c|test_d|test_e&lt;BR /&gt;test_a|test_b|test_c|test_d|test_e&lt;BR /&gt;a|b|3|4|5.0&lt;BR /&gt;a|b|3|4|5.0&lt;BR /&gt;a|b|3|4|5.0&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;hou could i do, thanks&lt;/P&gt;</description>
    <pubDate>Wed, 26 Jan 2022 01:48:05 GMT</pubDate>
    <dc:creator>zhangliang</dc:creator>
    <dc:date>2022-01-26T01:48:05Z</dc:date>
    <item>
      <title>how to replace value in file</title>
      <link>https://community.cloudera.com/t5/Support-Questions/how-to-replace-value-in-file/m-p/334482#M231788</link>
      <description>&lt;P&gt;There have some rows data with header in txt file, like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;test_a|test_b|test_c|test_d|test_e&lt;BR /&gt;a|b|3.0|4.0|5.0&lt;BR /&gt;a|b|3.0|4.0|5.0&lt;/P&gt;&lt;P&gt;a|b|3.0|4.0|5.0&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;now , i want&amp;nbsp; remove the value after test_c and test_d&amp;nbsp; decimal point,&amp;nbsp; the result change this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;test_a|test_b|test_c|test_d|test_e&lt;BR /&gt;a|b|3|4|5.0&lt;BR /&gt;a|b|3|4|5.0&lt;/P&gt;&lt;P&gt;a|b|3|4|5.0&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;how could i do? thanks.&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jan 2022 08:30:43 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/how-to-replace-value-in-file/m-p/334482#M231788</guid>
      <dc:creator>zhangliang</dc:creator>
      <dc:date>2022-01-25T08:30:43Z</dc:date>
    </item>
    <item>
      <title>Re: how to replace value in file</title>
      <link>https://community.cloudera.com/t5/Support-Questions/how-to-replace-value-in-file/m-p/334528#M231799</link>
      <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/95141"&gt;@zhangliang&lt;/a&gt;&amp;nbsp;to accomplish that i would use UpdateRecord&lt;/P&gt;&lt;P&gt;Since your data is csv and structured we can use record manipulation to accomplish this.&lt;/P&gt;&lt;P&gt;First I would treat all your values as string and build an avro schema to use:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="java"&gt;{
	"type":"record",
	"name":"nifiRecord",
	"namespace":"org.apache.nifi",
		"fields":[
			{"name":"test_a","type":["null","string"]},
			{"name":"test_b","type":["null","string"]},
			{"name":"test_c","type":["null","string"]},
			{"name":"test_d","type":["null","string"]},
			{"name":"test_e","type":["null","string"]}
		]
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then I would configure my UpdateRecord to use a CSV Reader and a CSV Writer&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would configure the CSV Reader like this:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 802px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/33242iF1F6F0FDD32A5004/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Use schema text property&lt;/P&gt;&lt;P&gt;Schema Text = Put your avro schema there&lt;/P&gt;&lt;P&gt;Value Separator = |&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And the CSV Writer leave everything default except:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Value Separator = |&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Finally the UpdateRecord processor will need 2 user fields.&lt;/P&gt;&lt;P&gt;In this case we want to update the fields "test_c" and "test_d"&lt;/P&gt;&lt;P&gt;And then we can use Record path manipulation and in particular for this use case the substringBefore function to only give us everything before the DOT "."&lt;/P&gt;&lt;P&gt;Here is what you should configure:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 802px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/33245iF794235AB8361538/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This will then take an input like this:&lt;/P&gt;&lt;LI-CODE lang="java"&gt;test_a|test_b|test_c|test_d|test_e
a|b|3.0|4.0|5.0
a|b|3.0|4.0|5.0
a|b|3.0|4.0|5.0&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and produce an output like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="java"&gt;test_a|test_b|test_c|test_d|test_e
a|b|3|4|5.0
a|b|3|4|5.0
a|b|3|4|5.0&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 25 Jan 2022 19:27:59 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/how-to-replace-value-in-file/m-p/334528#M231799</guid>
      <dc:creator>DigitalPlumber</dc:creator>
      <dc:date>2022-01-25T19:27:59Z</dc:date>
    </item>
    <item>
      <title>Re: how to replace value in file</title>
      <link>https://community.cloudera.com/t5/Support-Questions/how-to-replace-value-in-file/m-p/334544#M231806</link>
      <description>&lt;P&gt;thank you advice , I use you design, but i get the result like this, it has two row header:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;test_a|test_b|test_c|test_d|test_e&lt;BR /&gt;test_a|test_b|test_c|test_d|test_e&lt;BR /&gt;a|b|3|4|5.0&lt;BR /&gt;a|b|3|4|5.0&lt;BR /&gt;a|b|3|4|5.0&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;hou could i do, thanks&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jan 2022 01:48:05 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/how-to-replace-value-in-file/m-p/334544#M231806</guid>
      <dc:creator>zhangliang</dc:creator>
      <dc:date>2022-01-26T01:48:05Z</dc:date>
    </item>
    <item>
      <title>Re: how to replace value in file</title>
      <link>https://community.cloudera.com/t5/Support-Questions/how-to-replace-value-in-file/m-p/334587#M231821</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Most likely because on your CSV Reader you have:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Treat First Line as Header = false ( default )&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Change that to true&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jan 2022 14:25:48 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/how-to-replace-value-in-file/m-p/334587#M231821</guid>
      <dc:creator>DigitalPlumber</dc:creator>
      <dc:date>2022-01-26T14:25:48Z</dc:date>
    </item>
  </channel>
</rss>

