<?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: Split rows iteratively based on timestamp in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/Split-rows-iteratively-based-on-timestamp/m-p/2370383#M133432</link>
    <description>I have written a tutorial on Row Multiplication, which is what this is really. It doesn't cover your time logic, but to be honest that is relatively straight forward with a bit of Java. This tutorial covers how to multiply your rows. 
&lt;BR /&gt;
&lt;BR /&gt;
&lt;A href="https://www.rilhia.com/quicktips/quick-tip-row-multiplication" target="_blank" rel="nofollow noopener noreferrer"&gt;https://www.rilhia.com/quicktips/quick-tip-row-multiplication&lt;/A&gt;
&lt;BR /&gt;
&lt;BR /&gt;Where I am passing a "repeatRow" numeric value to the tJavaFlex, you could pass your StartDateTime and EndDateTime columns. Then calculate how many 30 minutes occur between your Start and End dates to identify the number of iterations of the loop. Then simply return the calculated time for each loop in the Main section.
&lt;BR /&gt;
&lt;BR /&gt;I hope it helps.</description>
    <pubDate>Thu, 02 Jun 2016 18:28:02 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2016-06-02T18:28:02Z</dc:date>
    <item>
      <title>Split rows iteratively based on timestamp</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Split-rows-iteratively-based-on-timestamp/m-p/2370381#M133430</link>
      <description>&lt;P&gt;Hello community,&lt;BR /&gt;I have a difficult requirement and I need ideas on how to implement this with Talend.&lt;BR /&gt;I have a table on a Redshift db with a startdatetime and a enddatetime column. What I need to do is split every row based on a 30-minute interval, until I reach the enddatetime value. Some examples to make myself clear:&lt;BR /&gt;[list=*]&lt;/P&gt; 
&lt;UL&gt; 
 &lt;LI&gt;Startdatetime:&amp;nbsp;2016-06-01 &lt;FONT color="#ff3333"&gt;03:27:21&lt;/FONT&gt; and Enddatetime:&amp;nbsp;2016-06-01 &lt;FONT color="#ff6633"&gt;04:13:05&lt;/FONT&gt; -&amp;gt; Final result should be 3 rows&lt;/LI&gt; 
&lt;/UL&gt; 
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; From &amp;nbsp;2016-06-01&amp;nbsp;&lt;FONT color="#ff3333"&gt;03:27:21 &lt;/FONT&gt;to&lt;FONT color="#ff3333"&gt;&amp;nbsp;&lt;/FONT&gt;2016-06-01&amp;nbsp;&lt;FONT color="#ff3333"&gt;03:30:00&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#ff3333"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/FONT&gt;From&lt;FONT color="#ff3333"&gt;&amp;nbsp;&lt;/FONT&gt;2016-06-01&amp;nbsp;&lt;FONT color="#ff3333"&gt;03:30:00 &lt;/FONT&gt;to&lt;FONT color="#ff3333"&gt;&amp;nbsp;&lt;/FONT&gt;2016-06-01&amp;nbsp;&lt;FONT color="#ff3333"&gt;04:00:00&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#ff3333"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/FONT&gt;From&lt;FONT color="#ff3333"&gt;&amp;nbsp;&lt;/FONT&gt;2016-06-01&amp;nbsp;&lt;FONT color="#ff3333"&gt;04:00:00&amp;nbsp;&lt;/FONT&gt;to&lt;FONT color="#ff3333"&gt;&amp;nbsp;&lt;/FONT&gt;2016-06-01&amp;nbsp;&lt;FONT color="#ff3333"&gt;04:13:05&lt;/FONT&gt;&lt;BR /&gt;[list=*]&lt;/P&gt; 
&lt;UL&gt; 
 &lt;LI&gt;Startdatetime:&amp;nbsp;2016-06-01 03:11:01 and Enddatetime:&amp;nbsp;2016-06-01 03:17:58 -&amp;gt; no split&lt;/LI&gt; 
&lt;/UL&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;UL&gt; 
 &lt;LI&gt;Startdatetime:&amp;nbsp;2016-06-01 03:54:26 and Enddatetime:&amp;nbsp;2016-06-01 04:11:10 -&amp;gt; Final result should be 2 rows&lt;/LI&gt; 
&lt;/UL&gt; 
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; From 2016-06-01 &lt;FONT color="#ff6633"&gt;03:54:26&lt;/FONT&gt; to 2016-06-01 &lt;FONT color="#ff6633"&gt;04:00:00&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; From 2016-06-01 &lt;FONT color="#ff6633"&gt;04:00:00&lt;/FONT&gt; to 2016-06-01 &lt;FONT color="#ff6633"&gt;04:11:10&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Intervals may range from a couple seconds to hours, so the number of splits is variable.&lt;BR /&gt;For now, I developed a query in Redshift to calculate for every row the first datetime split (2016-06-01&amp;nbsp;03:30:00 in my first example)&amp;nbsp;and be able to discriminate with a tFilterRow the rows that really need to be splitted: in this way I can also easily calculate the following datetime splits by simply adding 30 minutes.&lt;BR /&gt;&lt;BR /&gt;Now though, I don't know how to proceed. Can you advise me on the best Talend components to use? I probably need a loop somewhere, but I lack the general picture of the job, so to speak.&lt;BR /&gt;&lt;BR /&gt;Many thanks for your time,&lt;BR /&gt;Simona&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jun 2016 14:55:27 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Split-rows-iteratively-based-on-timestamp/m-p/2370381#M133430</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-06-02T14:55:27Z</dc:date>
    </item>
    <item>
      <title>Re: Split rows iteratively based on timestamp</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Split-rows-iteratively-based-on-timestamp/m-p/2370382#M133431</link>
      <description>You could probably use tJavaRow/tJavaFlex and tNormalize to create a new row that effectively looks like a pivot and then get the tNormalize (or I think there is a tUnpivotRow custom component) to spit out the multiple output rows...&lt;BR /&gt;M</description>
      <pubDate>Thu, 02 Jun 2016 16:27:23 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Split-rows-iteratively-based-on-timestamp/m-p/2370382#M133431</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-06-02T16:27:23Z</dc:date>
    </item>
    <item>
      <title>Re: Split rows iteratively based on timestamp</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Split-rows-iteratively-based-on-timestamp/m-p/2370383#M133432</link>
      <description>I have written a tutorial on Row Multiplication, which is what this is really. It doesn't cover your time logic, but to be honest that is relatively straight forward with a bit of Java. This tutorial covers how to multiply your rows. 
&lt;BR /&gt;
&lt;BR /&gt;
&lt;A href="https://www.rilhia.com/quicktips/quick-tip-row-multiplication" target="_blank" rel="nofollow noopener noreferrer"&gt;https://www.rilhia.com/quicktips/quick-tip-row-multiplication&lt;/A&gt;
&lt;BR /&gt;
&lt;BR /&gt;Where I am passing a "repeatRow" numeric value to the tJavaFlex, you could pass your StartDateTime and EndDateTime columns. Then calculate how many 30 minutes occur between your Start and End dates to identify the number of iterations of the loop. Then simply return the calculated time for each loop in the Main section.
&lt;BR /&gt;
&lt;BR /&gt;I hope it helps.</description>
      <pubDate>Thu, 02 Jun 2016 18:28:02 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Split-rows-iteratively-based-on-timestamp/m-p/2370383#M133432</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-06-02T18:28:02Z</dc:date>
    </item>
    <item>
      <title>Re: Split rows iteratively based on timestamp</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Split-rows-iteratively-based-on-timestamp/m-p/2370384#M133433</link>
      <description>most of the "calculation" will need to be done with custom java. Here's a quick example job --&amp;nbsp; 
&lt;BR /&gt; 
&lt;BR /&gt; 
&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009MFNL.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/139517iDE89BAA56424951E/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009MFNL.png" alt="0683p000009MFNL.png" /&gt;&lt;/span&gt; 
&lt;BR /&gt; 
&lt;BR /&gt;Fixed flow setup: 
&lt;BR /&gt; 
&lt;BR /&gt; 
&lt;BR /&gt; 
&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009MFNQ.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/130196i10F9307CED67AA61/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009MFNQ.png" alt="0683p000009MFNQ.png" /&gt;&lt;/span&gt; 
&lt;BR /&gt; 
&lt;BR /&gt;JavaFlex code: 
&lt;BR /&gt;start: 
&lt;BR /&gt; 
&lt;PRE&gt;//for outputting to row&lt;BR /&gt;Date outStart = null;&lt;BR /&gt;Date outEnd = null;&lt;BR /&gt;Boolean stop = false;&lt;BR /&gt;&lt;BR /&gt;//for pretty printing&lt;BR /&gt;java.text.SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");&lt;BR /&gt;&lt;BR /&gt;//setup StartDateTime&lt;BR /&gt;java.util.Calendar startDatetime = java.util.Calendar.getInstance(); // creates a new calendar instance&lt;BR /&gt;startDatetime.setTime((Date)globalMap.get("row1.startDatetime"));   // assigns calendar to given StartDatetime&lt;BR /&gt;&lt;BR /&gt;//setup EndDateTime&lt;BR /&gt;java.util.Calendar endDatetime = java.util.Calendar.getInstance(); // creates a new calendar instance&lt;BR /&gt;endDatetime.setTime((Date)globalMap.get("row1.endDatetime"));   // assigns calendar to given endDatetime&lt;BR /&gt;&lt;BR /&gt;//setup temp WorkingDateTime&lt;BR /&gt;java.util.Calendar workingDatetime = java.util.Calendar.getInstance();&lt;BR /&gt;workingDatetime.setTime((Date)globalMap.get("row1.startDatetime"));&lt;BR /&gt;&lt;BR /&gt;//set the working date to the first 30m marker&lt;BR /&gt;workingDatetime.set(java.util.Calendar.MINUTE,30);&lt;BR /&gt;workingDatetime.set(java.util.Calendar.SECOND, 00);&lt;BR /&gt;&lt;BR /&gt;if( workingDatetime.compareTo(startDatetime) &amp;gt; 0 ) {&lt;BR /&gt;	//everything is fine, our startDatetime was before the 30m mark&lt;BR /&gt;}&lt;BR /&gt;else {&lt;BR /&gt;	//our startDatetime is after the 30m mark&lt;BR /&gt;	workingDatetime.set(java.util.Calendar.MINUTE,00);&lt;BR /&gt;	workingDatetime.add(java.util.Calendar.HOUR, 1);&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;System.out.println(" Start " + f.format(startDatetime.getTime()) + " Working: " + f.format(workingDatetime.getTime()) + " End " + f.format(endDatetime.getTime()) );&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;do {&lt;/PRE&gt; 
&lt;BR /&gt; 
&lt;BR /&gt;Main: 
&lt;BR /&gt; 
&lt;PRE&gt;&lt;BR /&gt;if( workingDatetime.compareTo(endDatetime) &amp;gt; 0 ) {&lt;BR /&gt;	//we've already ranged over our endDatetime. means only one interval with startDateTime and endDateTime&lt;BR /&gt;	outStart = startDatetime.getTime();&lt;BR /&gt;	outEnd = endDatetime.getTime();&lt;BR /&gt;	stop = true;&lt;BR /&gt;}&lt;BR /&gt;else {&lt;BR /&gt;	outStart = startDatetime.getTime();&lt;BR /&gt;	outEnd = workingDatetime.getTime();&lt;BR /&gt;	&lt;BR /&gt;	//increment start&lt;BR /&gt;	startDatetime.setTime( workingDatetime.getTime() );&lt;BR /&gt;	//add 30 M to working datetime&lt;BR /&gt;	workingDatetime.add(java.util.Calendar.MINUTE, 30 );&lt;BR /&gt;}&lt;BR /&gt;//emit the rows&lt;BR /&gt;row2.startDatetime = outStart;&lt;BR /&gt;row2.endDatetime = outEnd;&lt;BR /&gt;&lt;/PRE&gt; 
&lt;BR /&gt;End: 
&lt;BR /&gt; 
&lt;PRE&gt;// end of the component, outside/closing the loop&lt;BR /&gt;} while ( !stop ); // end while&lt;BR /&gt;&lt;/PRE&gt; 
&lt;BR /&gt; 
&lt;BR /&gt;Output: 
&lt;BR /&gt; 
&lt;BR /&gt; 
&lt;BR /&gt; 
&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009MFNV.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/146019iF7F4DED45BD95793/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009MFNV.png" alt="0683p000009MFNV.png" /&gt;&lt;/span&gt;</description>
      <pubDate>Thu, 02 Jun 2016 19:09:53 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Split-rows-iteratively-based-on-timestamp/m-p/2370384#M133433</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-06-02T19:09:53Z</dc:date>
    </item>
  </channel>
</rss>

