<?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] Read expression/formula from excel file in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/resolved-Read-expression-formula-from-excel-file/m-p/2371355#M134306</link>
    <description>You can't do this.
&lt;BR /&gt;
&lt;FONT size="2"&gt;&lt;FONT face="consolas, monaco, 'bitstream vera sans mono', 'courier new', courier, monospace"&gt;row7.value1 + row7.value2 == 0 ? 0 : row7.value1/(row7.value1 + row7.value2) &lt;/FONT&gt;&lt;/FONT&gt;is simply a literal String.
&lt;BR /&gt;You want it to be compiled Java code but it can't be.</description>
    <pubDate>Wed, 27 Apr 2016 10:43:15 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2016-04-27T10:43:15Z</dc:date>
    <item>
      <title>[resolved] Read expression/formula from excel file</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-Read-expression-formula-from-excel-file/m-p/2371352#M134303</link>
      <description>Hi folks, 
&lt;BR /&gt;I'm quite new to Talend and would like to read an expression from a given file and then execute it in tMap. The expressions are stored in a separate excel column like this: 
&lt;BR /&gt; 
&lt;PRE&gt;row7.value1 + row7.value2 == 0 ? 0 : row7.value1/(row7.value1 + row7.value2)&lt;/PRE&gt; 
&lt;BR /&gt;I accomplished to read it as a string by global map:&amp;nbsp; 
&lt;FONT color="#242729"&gt;&lt;FONT face="Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif"&gt;((String) globalMap.get("row6.column_that_contains_expr"))&lt;/FONT&gt;&lt;/FONT&gt;. But I'm not able to execute the expression in order to get the resulting value.&amp;nbsp; 
&lt;BR /&gt;My job looks like this: 
&lt;BR /&gt; 
&lt;PRE&gt;tFileInputExcel =row6=&amp;gt; tFlowToIerate =&amp;gt; tPostgresqlInput =row7=&amp;gt; tMap =&amp;gt; tFileOutpuDelimited&lt;/PRE&gt; 
&lt;BR /&gt;Could you please tell me how to execute the expression from file and obtain the resulting 
&lt;B&gt;double&lt;/B&gt;? 
&lt;BR /&gt;Greetings 
&lt;BR /&gt;Simon</description>
      <pubDate>Tue, 26 Apr 2016 08:28:18 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-Read-expression-formula-from-excel-file/m-p/2371352#M134303</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-04-26T08:28:18Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] Read expression/formula from excel file</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-Read-expression-formula-from-excel-file/m-p/2371353#M134304</link>
      <description>Hi, 
&lt;BR /&gt; 
&lt;BLOCKQUOTE&gt; 
 &lt;TABLE border="1"&gt; 
  &lt;TBODY&gt; 
   &lt;TR&gt; 
    &lt;TD&gt;&lt;FONT size="2"&gt;&lt;FONT face="consolas, monaco, 'bitstream vera sans mono', 'courier new', courier, monospace"&gt;row7.value1 + row7.value2 == 0 ? 0 : row7.value1/(row7.value1 + row7.value2)&lt;/FONT&gt;&lt;/FONT&gt;&lt;/TD&gt; 
   &lt;/TR&gt; 
  &lt;/TBODY&gt; 
 &lt;/TABLE&gt; 
&lt;/BLOCKQUOTE&gt; 
&lt;BR /&gt; 
&lt;FONT size="2"&gt;&lt;FONT face="consolas, monaco, 'bitstream vera sans mono', 'courier new', courier, monospace"&gt;Could you please show us some screenshots of your excel file with expression/ formula cell? Can you read your excel file by a simple work flow: tfileinputexcel--&amp;gt;tLogrow?&lt;/FONT&gt;&lt;/FONT&gt; 
&lt;BR /&gt;Best regards 
&lt;BR /&gt;Sabrina 
&lt;BR /&gt;&amp;nbsp;</description>
      <pubDate>Wed, 27 Apr 2016 08:26:05 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-Read-expression-formula-from-excel-file/m-p/2371353#M134304</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-04-27T08:26:05Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] Read expression/formula from excel file</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-Read-expression-formula-from-excel-file/m-p/2371354#M134305</link>
      <description>Hi Sabrina, 
&lt;BR /&gt;thanks for your reply. This is how the excel file looks like: 
&lt;BR /&gt; 
&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009MDzh.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/129978i9A04981D4211AB08/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009MDzh.png" alt="0683p000009MDzh.png" /&gt;&lt;/span&gt; 
&lt;BR /&gt;The column "ETL_EXPRESSION" contains the expression I want to execute in tMap function. When I use ((String) globalMap.get("row6.ETL_EXPRESSION")) I only get the expression itself but not the calculated (double) value. 
&lt;BR /&gt; 
&lt;PRE&gt;Starte Job talend_test am 10:16 27/04/2016.&lt;BR /&gt; connecting to socket on port 3398&lt;BR /&gt; connected&lt;BR /&gt;KPI_ID: 100020|KPI_NAME: example_kpi|ETL_EXPRESSION: row7.value1 + row7.value2 == 0 ? 0 : row7.value1/(row7.value1 + row7.value2)&lt;BR /&gt; disconnected&lt;BR /&gt;Job talend_test endet am 10:16 27/04/2016. &lt;/PRE&gt; 
&lt;BR /&gt; 
&lt;BR /&gt;Greetings&amp;nbsp; 
&lt;BR /&gt;Simon</description>
      <pubDate>Wed, 27 Apr 2016 09:20:33 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-Read-expression-formula-from-excel-file/m-p/2371354#M134305</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-04-27T09:20:33Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] Read expression/formula from excel file</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-Read-expression-formula-from-excel-file/m-p/2371355#M134306</link>
      <description>You can't do this.
&lt;BR /&gt;
&lt;FONT size="2"&gt;&lt;FONT face="consolas, monaco, 'bitstream vera sans mono', 'courier new', courier, monospace"&gt;row7.value1 + row7.value2 == 0 ? 0 : row7.value1/(row7.value1 + row7.value2) &lt;/FONT&gt;&lt;/FONT&gt;is simply a literal String.
&lt;BR /&gt;You want it to be compiled Java code but it can't be.</description>
      <pubDate>Wed, 27 Apr 2016 10:43:15 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-Read-expression-formula-from-excel-file/m-p/2371355#M134306</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-04-27T10:43:15Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] Read expression/formula from excel file</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-Read-expression-formula-from-excel-file/m-p/2371356#M134307</link>
      <description>Hm, I can't store the expression from excel in a variable and then execute it? I used that feature in other BI-Tools very often (QlikView for example).</description>
      <pubDate>Wed, 27 Apr 2016 10:54:05 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-Read-expression-formula-from-excel-file/m-p/2371356#M134307</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-04-27T10:54:05Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] Read expression/formula from excel file</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-Read-expression-formula-from-excel-file/m-p/2371357#M134308</link>
      <description>How does the tool know that the variable is holding an expression and not a String? I suspect that this is a niche piece of functionality used by QlikView. A bit of Googling also shows that the Excel is also used as part of the framework and not a consumable, which it is in Talend. If you want to store equations/functions/methods somewhere in Talend, you can use the Java routines (basically you can write them into Java classes). In fact, you can use ANY Java API you want with Talend.&amp;nbsp;</description>
      <pubDate>Wed, 27 Apr 2016 11:33:10 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-Read-expression-formula-from-excel-file/m-p/2371357#M134308</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-04-27T11:33:10Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] Read expression/formula from excel file</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-Read-expression-formula-from-excel-file/m-p/2371358#M134309</link>
      <description>&lt;FONT color="#242729"&gt;&lt;FONT face="Arial, 'Helvetica Neue', Helvetica, sans-serif"&gt;Hi,&lt;/FONT&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#242729"&gt;&lt;FONT face="Arial, 'Helvetica Neue', Helvetica, sans-serif"&gt;I tried the following in tJavaRow:&lt;/FONT&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;PRE&gt;ScriptEngineManager mgr = new ScriptEngineManager();&amp;nbsp;&lt;BR /&gt;ScriptEngine engine = mgr.getEngineByName("JavaScript"); &lt;BR /&gt;String infix = "row7.value1 + row7.value2 == 0 ? 0 : row7.value1/(row7.value1 + row7.value2)"; &lt;BR /&gt;context.test = engine.eval(infix);&amp;nbsp;&lt;/PRE&gt;&lt;BR /&gt;&lt;FONT color="#242729"&gt;&lt;FONT face="Arial, 'Helvetica Neue', Helvetica, sans-serif"&gt;Which leads to an error:&lt;/FONT&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;PRE&gt;&amp;nbsp;javax.script.ScriptException: ReferenceError: "row7" is not defined in &amp;lt;eval&amp;gt;&amp;nbsp;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT color="#242729"&gt;&lt;FONT face="Arial, 'Helvetica Neue', Helvetica, sans-serif"&gt;Any Ideas?&lt;/FONT&gt;&lt;/FONT&gt;</description>
      <pubDate>Fri, 29 Apr 2016 11:21:26 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-Read-expression-formula-from-excel-file/m-p/2371358#M134309</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-04-29T11:21:26Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] Read expression/formula from excel file</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-Read-expression-formula-from-excel-file/m-p/2371359#M134310</link>
      <description>I don't understand what you are trying do here. All you need to do to assign the value to the context variable is....
&lt;BR /&gt;
&lt;PRE&gt;context.test = (row7.value1 + row7.value2 == 0 ? 0 : row7.value1/(row7.value1 + row7.value2));&lt;/PRE&gt;
&lt;BR /&gt;By wrapping "
&lt;FONT size="2"&gt;&lt;FONT face="consolas, monaco, 'bitstream vera sans mono', 'courier new', courier, monospace"&gt;row7.value1 + row7.value2 == 0 ? 0 : row7.value1/(row7.value1 + row7.value2) "&lt;/FONT&gt;&lt;/FONT&gt;&amp;nbsp;in quotes, you are essentially just creating a String.&amp;nbsp;
&lt;BR /&gt;The ScriptEngine object you are using is trying to run JavaScript. This is a scripting language which has no relationship to objects created by Talend (ie row7.value1, etc). These are Java objects.
&lt;BR /&gt;If you are trying to use data driven dynamic transformations, you can do that, but you will need to either build them using tMap (or similar Talend components) or write Java classes (routines in Talend) to achieve this.&amp;nbsp;</description>
      <pubDate>Fri, 29 Apr 2016 13:10:37 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-Read-expression-formula-from-excel-file/m-p/2371359#M134310</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-04-29T13:10:37Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] Read expression/formula from excel file</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-Read-expression-formula-from-excel-file/m-p/2371360#M134311</link>
      <description>All I'm trying to do is to read an (Talend) expression from a flat-file and then execute it in tMap. But like you said it's interpreted as a String... So I guess I've to write my own classes&amp;nbsp;and methods in Talend that would be able to interpret the formula I get from the file - like you suggested. Thanks!</description>
      <pubDate>Fri, 29 Apr 2016 13:36:08 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-Read-expression-formula-from-excel-file/m-p/2371360#M134311</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-04-29T13:36:08Z</dc:date>
    </item>
  </channel>
</rss>

