<?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>topic Re: add characters to a string to make it constant length in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/add-characters-to-a-string-to-make-it-constant-length/m-p/2376353#M138550</link>
    <description>Hi,
&lt;BR /&gt;I think you want to right pad your strings with a "0" character. Use the Commons Lang StringUtils class that's available. This function right pads a string to 7 characters.
&lt;BR /&gt;StringUtils.rightPad("CCCC", 7, "0");
&lt;BR /&gt;This post shows how to access the Lang JAR that's provided with Talend.
&lt;BR /&gt;
&lt;A href="http://bekwam.blogspot.com/2011/01/java-libraries-in-talend-open-studio.html" rel="nofollow noopener noreferrer"&gt;http://bekwam.blogspot.com/2011/01/java-libraries-in-talend-open-studio.html&lt;/A&gt;</description>
    <pubDate>Fri, 06 Apr 2012 15:24:25 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2012-04-06T15:24:25Z</dc:date>
    <item>
      <title>add characters to a string to make it constant length</title>
      <link>https://community.qlik.com/t5/Talend-Studio/add-characters-to-a-string-to-make-it-constant-length/m-p/2376350#M138547</link>
      <description>Hi,&lt;BR /&gt;I have a sting which carries multiple codes so if it has one code, its length is 4 if it has to codes its length is 8 if 3 then 12.&lt;BR /&gt;I want to add 0000 wherever a code is absent so that I can parse the code into strings of 4 characters using substring() in tmap.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Karan</description>
      <pubDate>Thu, 05 Apr 2012 23:12:36 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/add-characters-to-a-string-to-make-it-constant-length/m-p/2376350#M138547</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-04-05T23:12:36Z</dc:date>
    </item>
    <item>
      <title>Re: add characters to a string to make it constant length</title>
      <link>https://community.qlik.com/t5/Talend-Studio/add-characters-to-a-string-to-make-it-constant-length/m-p/2376351#M138548</link>
      <description>Hi Karan&lt;BR /&gt;Could you explain it in another way?&lt;BR /&gt;Regards,&lt;BR /&gt;Pedro</description>
      <pubDate>Fri, 06 Apr 2012 02:57:11 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/add-characters-to-a-string-to-make-it-constant-length/m-p/2376351#M138548</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-04-06T02:57:11Z</dc:date>
    </item>
    <item>
      <title>Re: add characters to a string to make it constant length</title>
      <link>https://community.qlik.com/t5/Talend-Studio/add-characters-to-a-string-to-make-it-constant-length/m-p/2376352#M138549</link>
      <description>Sure. 
&lt;BR /&gt;Below is what I want to achieve and I am using substing(0,4) &amp;amp; substring (4,8) in tmap to generate output fields 1 &amp;amp; 2 respectively. 
&lt;BR /&gt;1)input field1:AAAABBBB &amp;gt;&amp;gt; Output field1: AAAA Output field2:BBBB 
&lt;BR /&gt;2)input field1:CCCC &amp;gt;&amp;gt; Output field1: CCCC Output field2:&amp;lt;null&amp;gt; 
&lt;BR /&gt;3)input field1 
&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009MACJ.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/133049iD780B7DE0116E4D1/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009MACJ.png" alt="0683p000009MACJ.png" /&gt;&lt;/span&gt;DDD0000 &amp;gt;&amp;gt; Output field1: DDDD Output field2:0000 
&lt;BR /&gt;but since the input field in 2nd row is only 4 characters long, it goes "string index out of bounds" while generating output field2 since the length is 4 &amp;amp; not 8. 
&lt;BR /&gt;So I wanted to convert inout field1 in row 2 from CCCC to CCCC0000 so that it gets treated as row 3. 
&lt;BR /&gt; 
&lt;BR /&gt;Since there are only 11 instances of 4 character long values, I tried to use if else in tmap but it is not giving the desired output.It always gives the input as output. My expression is as below 
&lt;BR /&gt;StringHandling.LEN(row3.SIC_CD) == 4 ? row3.SIC_CD + "0000" : row3.SIC_CD 
&lt;BR /&gt; 
&lt;BR /&gt;Thanks, 
&lt;BR /&gt;Karan</description>
      <pubDate>Fri, 06 Apr 2012 15:01:14 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/add-characters-to-a-string-to-make-it-constant-length/m-p/2376352#M138549</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-04-06T15:01:14Z</dc:date>
    </item>
    <item>
      <title>Re: add characters to a string to make it constant length</title>
      <link>https://community.qlik.com/t5/Talend-Studio/add-characters-to-a-string-to-make-it-constant-length/m-p/2376353#M138550</link>
      <description>Hi,
&lt;BR /&gt;I think you want to right pad your strings with a "0" character. Use the Commons Lang StringUtils class that's available. This function right pads a string to 7 characters.
&lt;BR /&gt;StringUtils.rightPad("CCCC", 7, "0");
&lt;BR /&gt;This post shows how to access the Lang JAR that's provided with Talend.
&lt;BR /&gt;
&lt;A href="http://bekwam.blogspot.com/2011/01/java-libraries-in-talend-open-studio.html" rel="nofollow noopener noreferrer"&gt;http://bekwam.blogspot.com/2011/01/java-libraries-in-talend-open-studio.html&lt;/A&gt;</description>
      <pubDate>Fri, 06 Apr 2012 15:24:25 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/add-characters-to-a-string-to-make-it-constant-length/m-p/2376353#M138550</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-04-06T15:24:25Z</dc:date>
    </item>
    <item>
      <title>Re: add characters to a string to make it constant length</title>
      <link>https://community.qlik.com/t5/Talend-Studio/add-characters-to-a-string-to-make-it-constant-length/m-p/2376354#M138551</link>
      <description>Thanks for the response. 
&lt;BR /&gt;This one is hard coded to add padding to "CCCC" how can I switch it to add padding only if the length is 4? 
&lt;BR /&gt;I have a head start at this by using the expression 
&lt;BR /&gt;StringHandling.LEN(row3.SIC_CD) == 4 ? row3.SIC_CD + "0000" : row3.SIC_CD 
&lt;BR /&gt;Unfortunately it is not giving the desired output. It gives 
&lt;BR /&gt;AAAABBBB 
&lt;BR /&gt;CCCC 
&lt;BR /&gt;DDDD0000 
&lt;BR /&gt;I want 
&lt;BR /&gt;AAAABBBB 
&lt;BR /&gt;CCCC0000 
&lt;BR /&gt;DDDD0000 
&lt;BR /&gt; 
&lt;BR /&gt;Best, 
&lt;BR /&gt;Karan</description>
      <pubDate>Fri, 06 Apr 2012 15:38:58 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/add-characters-to-a-string-to-make-it-constant-length/m-p/2376354#M138551</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-04-06T15:38:58Z</dc:date>
    </item>
    <item>
      <title>Re: add characters to a string to make it constant length</title>
      <link>https://community.qlik.com/t5/Talend-Studio/add-characters-to-a-string-to-make-it-constant-length/m-p/2376355#M138552</link>
      <description>I'm not sure why LEN isn't working for you.  I put up a blog post on how to pad a string with StringUtils.rightPad: &lt;A href="http://bekwam.blogspot.com/2012/04/right-padding-string-with-talend-open.html" rel="nofollow noopener noreferrer"&gt;http://bekwam.blogspot.com/2012/04/right-padding-string-with-talend-open.html&lt;/A&gt;.</description>
      <pubDate>Fri, 06 Apr 2012 17:03:20 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/add-characters-to-a-string-to-make-it-constant-length/m-p/2376355#M138552</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-04-06T17:03:20Z</dc:date>
    </item>
  </channel>
</rss>

