<?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/177555#M139803</link>
    <description>&lt;P&gt;Hi @Shu, thanks for the detailed reply. But I would prefer using Record-based processors (such as &lt;STRONG&gt;SplitRecord &lt;/STRONG&gt;and &lt;STRONG&gt;UpdateRecord&lt;/STRONG&gt;) since &lt;STRONG&gt;CSV &lt;/STRONG&gt;is considered record-based as well. But I am faced with a problem and can't figure it out. I would appreciate if you could suggest a solution or point me in the right direction.&lt;/P&gt;&lt;P&gt;Here is what I have done:&lt;/P&gt;&lt;P&gt;create sample csv file&lt;/P&gt;&lt;PRE&gt;name,age,height,weight,school 
james, 19, 173, 56, NY
jake, 20, 177, 62, MD 
sam, 21, 160, 55, KN
Mike, 24, 170, 64, MM&lt;/PRE&gt;&lt;P&gt;created &lt;STRONG&gt;AvroSchemaRegistry&lt;/STRONG&gt;&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;/PRE&gt;&lt;P&gt;Then &lt;STRONG&gt;CSVReader &lt;/STRONG&gt;and &lt;STRONG&gt;CSVRecordSetWriter &lt;/STRONG&gt;contoller services (referencing the same AvroSchema)&lt;/P&gt;&lt;P&gt;Then using &lt;STRONG&gt;UpdateAttribute&lt;/STRONG&gt; I update the file's attribute by adding property &lt;STRONG&gt;schema.name=&lt;/STRONG&gt;&lt;EM&gt;thename&lt;BR /&gt;&lt;/EM&gt;This successfully adds the attribute. Afterwards, I use &lt;STRONG&gt;SpliteRecord &lt;/STRONG&gt;and set the &lt;STRONG&gt;Record Reader &lt;/STRONG&gt;and &lt;STRONG&gt;Record Writer &lt;/STRONG&gt;property as appropriate (&lt;STRONG&gt;Records Per Split = 1&lt;/STRONG&gt;). It does split the file into 4 records as expected. &lt;BR /&gt;Then I use &lt;STRONG&gt;UpdateRecord&lt;/STRONG&gt;. And again set &lt;STRONG&gt;Record Reader &lt;/STRONG&gt;and &lt;STRONG&gt;Record Writer&lt;/STRONG&gt;. And for &lt;STRONG&gt;Replacement Value Strategy &lt;/STRONG&gt;I set value to &lt;STRONG&gt;Literal Value&lt;/STRONG&gt; for simplicity. Then add a property as below&lt;/P&gt;&lt;PRE&gt;/fields[2]/height = 2222&lt;/PRE&gt;&lt;P&gt;Then I get the 4 records (as expected) coming from &lt;STRONG&gt;UpdateRecord&lt;/STRONG&gt;. But they are all size=0. I can't understand why would it return size 0.&lt;/P&gt;&lt;P&gt;Any help would be appreciated.&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
    <pubDate>Thu, 05 Oct 2017 21:49:05 GMT</pubDate>
    <dc:creator>samgoldopamp</dc:creator>
    <dc:date>2017-10-05T21:49:05Z</dc:date>
  </channel>
</rss>

