<?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: add field to csv file based on other field value in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/add-field-to-csv-file-based-on-other-field-value/m-p/177560#M139808</link>
    <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/20202/samgoldopamp.html" nodeid="20202" target="_blank"&gt;@Sammy Gold&lt;/A&gt;, &lt;/P&gt;&lt;P&gt;i tried to add new element to the csv content we can add new field by changing AvroSchemaRegistry to below&lt;/P&gt;&lt;PRE&gt;{"name": "origFormatName","namespace": "someFields","type": "record","fields": [{ "name": "name", "type": "string" },{ "name": "age", "type": "int" },{ "name": "height", "type": "int" },{ "name": "weight", "type": "int" },{ "name": "school", "type": "string" },&lt;STRONG&gt;{ "name": "heightmm", "type": "int" }]}&lt;/STRONG&gt;&lt;STRONG&gt; &lt;/STRONG&gt;&lt;/PRE&gt;&lt;P&gt;but we&lt;STRONG&gt; cannot do math calculations&lt;/STRONG&gt; i think..&lt;/P&gt;&lt;P&gt;&lt;U&gt;Following things i tried:-&lt;/U&gt;&lt;/P&gt;&lt;P&gt;Replacement value strategy as&lt;STRONG&gt; Record Path value&lt;/STRONG&gt; but &lt;STRONG&gt;it wont does any math&lt;/STRONG&gt; on the existing &lt;STRONG&gt;/height&lt;/STRONG&gt; field&lt;/P&gt;&lt;PRE&gt;/heightmm as /height*10,/height:multiply(10)&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;When can this processor works to add values?&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;It will work if you are going to have heightmm value as /height value then this processor works&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Replacement value strategy&lt;/STRONG&gt; as&lt;STRONG&gt; Record Path value&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;/heightmm as /height&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;Example:-&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;name,age,height,weight,school,heightmm &lt;BR /&gt; james,19,2222,56,,2222 
jake,20,2222,62,,2222 
sam,21,2222,55,,2222 
Mike,24,2222,64,,2222&lt;/PRE&gt;&lt;P&gt;we can &lt;STRONG&gt;replace&lt;/STRONG&gt; only with the &lt;STRONG&gt;existing values,&lt;/STRONG&gt; but we cannot do math operations i think.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Another way:-&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;To add new record for the existing csv data you can &lt;STRONG&gt;extract the height content as attribute&lt;/STRONG&gt; by using extract attribute processor and use replace text processor to create new record based on height attribute.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="40763-screenshot.png" style="width: 552px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/19567iF1B1C4BA219CB8BC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="40763-screenshot.png" alt="40763-screenshot.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;here we are keeping &lt;/P&gt;&lt;PRE&gt;Replacement Strategy property to Append &lt;/PRE&gt;&lt;P&gt;it will &lt;STRONG&gt;keeps the content as is&lt;/STRONG&gt; and &lt;STRONG&gt;append the new value&lt;/STRONG&gt; to the content.&lt;/P&gt;&lt;P&gt;(or)&lt;/P&gt;&lt;P&gt;you can use &lt;/P&gt;&lt;PRE&gt;Replacement Strategy property to regexreplace&lt;/PRE&gt;&lt;PRE&gt;Replacement value as $1${height:multiply(10)} &lt;/PRE&gt;&lt;P&gt;it will give &lt;STRONG&gt;same result&lt;/STRONG&gt; as&lt;STRONG&gt; Append&lt;/STRONG&gt; method did.&lt;/P&gt;</description>
    <pubDate>Sun, 18 Aug 2019 09:42:23 GMT</pubDate>
    <dc:creator>Shu_ashu</dc:creator>
    <dc:date>2019-08-18T09:42:23Z</dc:date>
  </channel>
</rss>

