<?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: [resolved] How to do for loop in Express code edit in tMap in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/resolved-How-to-do-for-loop-in-Express-code-edit-in-tMap/m-p/2221314#M15367</link>
    <description>Hi, YinZhong.. 
&lt;BR /&gt;tMap is an advanced component that transforms and routes data from single or multiple sources to single or multiple destinations. 
&lt;BR /&gt;since we all here didn't how your data structures look like, what can be done is, creating a Java routine to perform the looping part, something like: 
&lt;BR /&gt; 
&lt;PRE&gt;eg:&lt;BR /&gt;int[] values = new int;&lt;BR /&gt;// Loop over all the elements in the values array&lt;BR /&gt;for (int i=0; i&amp;lt;values.length; i++) {&lt;BR /&gt;  // Do something with values&lt;I&gt;, such as print it&lt;BR /&gt;  System.out.println( values&lt;I&gt; );&lt;BR /&gt;}&lt;BR /&gt;OR&lt;BR /&gt;eg:&lt;BR /&gt;// Find-Max&lt;BR /&gt;// Given a non-empty array of ints, returns&lt;BR /&gt;// the largest int value found in the array.&lt;BR /&gt;// (does not work with empty arrays)&lt;BR /&gt;public int findMax(int[] nums) {&lt;BR /&gt;  int maxCounter = nums;  // use nums as the max to start&lt;BR /&gt;  // Look at every element, starting at 1&lt;BR /&gt;  for (int i=1; i&amp;lt;nums.length; i++) {&lt;BR /&gt;    if (nums&lt;I&gt; &amp;gt; maxCounter) {&lt;BR /&gt;      maxCounter = nums&lt;I&gt;;&lt;BR /&gt;    }&lt;BR /&gt;  }&lt;BR /&gt;  return maxCounter;&lt;BR /&gt;}&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/PRE&gt; 
&lt;BR /&gt;so no, you cannot do a loop within tMap but yes, you can do the looping either with tLoop/other related components + Java routine to do the processing (eg: creating a loop and store the data inside an array, etc..) 
&lt;BR /&gt;that's the rough idea.. 
&lt;BR /&gt;hmm, maybe other members here got a better idea? 
&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009MACn.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/154443iC5B8CACEF3D12C6A/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009MACn.png" alt="0683p000009MACn.png" /&gt;&lt;/span&gt;</description>
    <pubDate>Thu, 27 Nov 2014 02:39:45 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2014-11-27T02:39:45Z</dc:date>
    <item>
      <title>[resolved] How to do for loop in Express code edit in tMap</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-How-to-do-for-loop-in-Express-code-edit-in-tMap/m-p/2221311#M15364</link>
      <description>I am evaluating on Talend DI for my company for efferent Data Integration tool.&amp;nbsp; 
&lt;BR /&gt;Following is a for loop in my project that using another Data Integration tool. 
&lt;BR /&gt;============================================== 
&lt;BR /&gt;' Fill SegmentArray for each record in process, the SegmentArray is a global array variable 
&lt;BR /&gt;SegeType = Records("R1").Fields("MARKET_SEGEMENT") ' Get the SegeType from the field MARKET_SEGEMENT 
&lt;BR /&gt;SegNumber = 100 
&lt;BR /&gt;for i = 1 to SegCount 
&lt;BR /&gt;&amp;nbsp; if SegmentArray(i,1) = "" then 
&lt;BR /&gt;&amp;nbsp; &amp;nbsp; if SegNumber = 100 then 
&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; SegmentArray(i,1) = SegeType 
&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; SegNumber = i 
&lt;BR /&gt;&amp;nbsp; &amp;nbsp; end if &amp;nbsp; 
&lt;BR /&gt;&amp;nbsp; elseif SegmentArray(i,1) = SegeType then 
&lt;BR /&gt;&amp;nbsp; &amp;nbsp; SegNumber = i 
&lt;BR /&gt;&amp;nbsp; end if&amp;nbsp; 
&lt;BR /&gt;next i 
&lt;BR /&gt;SegmentArray(SegNumber,2) = SegmentArray(SegNumber,2) + 1 
&lt;BR /&gt;SegmentArray(SegNumber,3) = SegmentArray(SegNumber,3) + Val(Records("R1").Fields("BILLED_AMT")) 
&lt;BR /&gt;============================================== 
&lt;BR /&gt;I need to find out how to do this kind for loop in tMap Expressiong editor.</description>
      <pubDate>Wed, 26 Nov 2014 15:51:18 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-How-to-do-for-loop-in-Express-code-edit-in-tMap/m-p/2221311#M15364</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-11-26T15:51:18Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] How to do for loop in Express code edit in tMap</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-How-to-do-for-loop-in-Express-code-edit-in-tMap/m-p/2221312#M15365</link>
      <description>Hi, YinZhong.. 
&lt;BR /&gt;can you please explain what kind of data that you have and what do you want to achieve using more simple explanations? 
&lt;BR /&gt;this is just my guess, but maybe you can use tFlowToIterate component: 
&lt;BR /&gt; 
&lt;PRE&gt;tFlowToIterate iterates on the input data and generates global variables.&lt;/PRE&gt; 
&lt;BR /&gt; 
&lt;BR /&gt; 
&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009MACn.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/154443iC5B8CACEF3D12C6A/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009MACn.png" alt="0683p000009MACn.png" /&gt;&lt;/span&gt;</description>
      <pubDate>Wed, 26 Nov 2014 19:08:33 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-How-to-do-for-loop-in-Express-code-edit-in-tMap/m-p/2221312#M15365</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-11-26T19:08:33Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] How to do for loop in Express code edit in tMap</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-How-to-do-for-loop-in-Express-code-edit-in-tMap/m-p/2221313#M15366</link>
      <description>Hi Shy_Angel: 
&lt;BR /&gt;My project is to map data for bill print. The source record have a field called Market_segment. There are about 10 Market_segment code used in the data file. Other than data map, I also need to create a report that can list summery data for each Market_segment. I create a array to save these data and gathering these data when tMap process each source records. That is why I need to do a for loop in expression code editor inside tMap. 
&lt;BR /&gt;Last time you have helped me to do if statement that is very helpful to my project. This time I want to see if it is possible to do for loop inside tMap or not. 
&lt;BR /&gt;Regards 
&lt;BR /&gt;Yin Zhong</description>
      <pubDate>Wed, 26 Nov 2014 20:53:47 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-How-to-do-for-loop-in-Express-code-edit-in-tMap/m-p/2221313#M15366</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-11-26T20:53:47Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] How to do for loop in Express code edit in tMap</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-How-to-do-for-loop-in-Express-code-edit-in-tMap/m-p/2221314#M15367</link>
      <description>Hi, YinZhong.. 
&lt;BR /&gt;tMap is an advanced component that transforms and routes data from single or multiple sources to single or multiple destinations. 
&lt;BR /&gt;since we all here didn't how your data structures look like, what can be done is, creating a Java routine to perform the looping part, something like: 
&lt;BR /&gt; 
&lt;PRE&gt;eg:&lt;BR /&gt;int[] values = new int;&lt;BR /&gt;// Loop over all the elements in the values array&lt;BR /&gt;for (int i=0; i&amp;lt;values.length; i++) {&lt;BR /&gt;  // Do something with values&lt;I&gt;, such as print it&lt;BR /&gt;  System.out.println( values&lt;I&gt; );&lt;BR /&gt;}&lt;BR /&gt;OR&lt;BR /&gt;eg:&lt;BR /&gt;// Find-Max&lt;BR /&gt;// Given a non-empty array of ints, returns&lt;BR /&gt;// the largest int value found in the array.&lt;BR /&gt;// (does not work with empty arrays)&lt;BR /&gt;public int findMax(int[] nums) {&lt;BR /&gt;  int maxCounter = nums;  // use nums as the max to start&lt;BR /&gt;  // Look at every element, starting at 1&lt;BR /&gt;  for (int i=1; i&amp;lt;nums.length; i++) {&lt;BR /&gt;    if (nums&lt;I&gt; &amp;gt; maxCounter) {&lt;BR /&gt;      maxCounter = nums&lt;I&gt;;&lt;BR /&gt;    }&lt;BR /&gt;  }&lt;BR /&gt;  return maxCounter;&lt;BR /&gt;}&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/PRE&gt; 
&lt;BR /&gt;so no, you cannot do a loop within tMap but yes, you can do the looping either with tLoop/other related components + Java routine to do the processing (eg: creating a loop and store the data inside an array, etc..) 
&lt;BR /&gt;that's the rough idea.. 
&lt;BR /&gt;hmm, maybe other members here got a better idea? 
&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009MACn.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/154443iC5B8CACEF3D12C6A/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009MACn.png" alt="0683p000009MACn.png" /&gt;&lt;/span&gt;</description>
      <pubDate>Thu, 27 Nov 2014 02:39:45 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-How-to-do-for-loop-in-Express-code-edit-in-tMap/m-p/2221314#M15367</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-11-27T02:39:45Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] How to do for loop in Express code edit in tMap</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-How-to-do-for-loop-in-Express-code-edit-in-tMap/m-p/2221315#M15368</link>
      <description>Thank you very much. I found tJavaRow is a good component that allow me to add code for row by row transform.&lt;BR /&gt;tFileInputDelimited ---&amp;gt;tMap---&amp;gt;tJavaRow---&amp;gt;tFileOutputDelimited.</description>
      <pubDate>Mon, 01 Dec 2014 22:30:42 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-How-to-do-for-loop-in-Express-code-edit-in-tMap/m-p/2221315#M15368</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-12-01T22:30:42Z</dc:date>
    </item>
  </channel>
</rss>

