<?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] Use tJavaRow to get fieldname and fieldvalue in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/resolved-Use-tJavaRow-to-get-fieldname-and-fieldvalue/m-p/2314348#M85124</link>
    <description>Well in Enterprise version of Talend there is available Dynamic type schema, which is an object, whick you can query and it gives you dynamically any input structure (name of the fields) and you could iterate trough those and based on names obtain for each row the values. 
&lt;BR /&gt;In case your input message even with different columns is still the same (CSV file), it is not hard to write such java lib and forget about Talend tFileInputDelimited etc if you have only Open Source edition, you could use it as orchestrator only. 
&lt;BR /&gt;When this component obtain a key-value I suggest appending this into this structure - MultiMap ( 
&lt;A href="https://google.github.io/guava/releases/19.0/api/docs/com/google/common/collect/Multimap.html" target="_blank" rel="nofollow noopener noreferrer"&gt;https://google.github.io/guava/releases/19.0/api/docs/com/google/common/collect/Multimap.html&lt;/A&gt;)&amp;nbsp; 
&lt;BR /&gt;Then you can overide method .toString() or implement new one to print the data in the way you like. 
&lt;BR /&gt;If the insertion order is important, then go ahead with&amp;nbsp; 
&lt;A href="https://google.github.io/guava/releases/19.0/api/docs/com/google/common/collect/LinkedListMultimap.html" target="_blank" rel="nofollow noopener noreferrer"&gt;https://google.github.io/guava/releases/19.0/api/docs/com/google/common/collect/LinkedListMultimap.html&lt;/A&gt; 
&lt;BR /&gt;and that's it. I hope I understood your requirement correctly. 
&lt;BR /&gt;In general Talend won't help you in this case unless you have Enterprise edition and access to Dynamic schema, so do it by hand I suggest.</description>
    <pubDate>Fri, 24 Mar 2017 12:58:25 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2017-03-24T12:58:25Z</dc:date>
    <item>
      <title>[resolved] Use tJavaRow to get fieldname and fieldvalue</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-Use-tJavaRow-to-get-fieldname-and-fieldvalue/m-p/2314343#M85119</link>
      <description>Hi guys, 
&lt;BR /&gt;I want to dynamically pick the field names and values of input flow so that I can output them as a single string. 
&lt;BR /&gt;This is because I have no control over the incoming messages but they all go through a tMap component.&amp;nbsp; 
&lt;BR /&gt;So, assuming we have incoming data in the format: 
&lt;BR /&gt; 
&lt;BR /&gt; 
&lt;PRE&gt;CustomerID|CustomerName&lt;BR /&gt;123|John Doe&lt;BR /&gt;456|Jane Doe&lt;BR /&gt;&lt;/PRE&gt; 
&lt;BR /&gt;I want to loop through all the columns and give the output as column_name=column_value,column_name=column_value; ... 
&lt;BR /&gt; 
&lt;PRE&gt;I.e. CustomerID=123,CustomerName=John Doe;CustomerID=456,CustomerName=Jane Doe;...&lt;/PRE&gt; 
&lt;BR /&gt;Using the advice from&amp;nbsp; 
&lt;A href="https://community.qlik.com/s/feed/0D53p00007vCp3ICAS" target="_blank" rel="nofollow noopener noreferrer"&gt;https://community.talend.com/t5/Design-and-Development/resolved-how-to-get-the-column-names-in-a-data-flow/td-p/99172&lt;/A&gt;&amp;nbsp;I was able to get the field names by looping through the tMap output columns.&amp;nbsp; 
&lt;BR /&gt;Now I want to know how to get the field values. I know I can use the code&amp;nbsp; 
&lt;BR /&gt; 
&lt;PRE&gt;output_row.OutString = input_row.CustomerID;&amp;nbsp;&lt;/PRE&gt; 
&lt;BR /&gt;to get the field value but for this I have to give the explicit column name (CustomerID) and that's what I'm trying to avoid.</description>
      <pubDate>Fri, 17 Mar 2017 10:45:52 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-Use-tJavaRow-to-get-fieldname-and-fieldvalue/m-p/2314343#M85119</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-03-17T10:45:52Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] Use tJavaRow to get fieldname and fieldvalue</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-Use-tJavaRow-to-get-fieldname-and-fieldvalue/m-p/2314344#M85120</link>
      <description>&lt;PRE&gt;CustomerID|CustomerName&lt;/PRE&gt;
&lt;BR /&gt;This line is the column name or the first row of incoming message? Which components do you use in the job?&amp;nbsp;How do you define the schema? Just want to find out your needs, so that&amp;nbsp;I can give your accurate answer.
&lt;BR /&gt;Regards
&lt;BR /&gt;Shong</description>
      <pubDate>Mon, 20 Mar 2017 04:45:37 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-Use-tJavaRow-to-get-fieldname-and-fieldvalue/m-p/2314344#M85120</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-03-20T04:45:37Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] Use tJavaRow to get fieldname and fieldvalue</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-Use-tJavaRow-to-get-fieldname-and-fieldvalue/m-p/2314345#M85121</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;This line is the column name or the first row of incoming message?&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;Yes, this is the column name.&lt;BR /&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Which components do you use in the job?&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;xmlFileInput -&amp;gt; tMap -&amp;gt; tJavaRow -&amp;gt; tLogRow&lt;BR /&gt;The xml files are simple enough for tMap to be sufficient. I'm not using the tXmlMap.&lt;BR /&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;How do you define the schema?&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;I've defined the metadata in the repository for the input xmls.&lt;BR /&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Just want to find out your needs, so that I can give your accurate answer.&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;Much appreciated. Let me know if the responses are sufficient</description>
      <pubDate>Mon, 20 Mar 2017 06:40:26 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-Use-tJavaRow-to-get-fieldname-and-fieldvalue/m-p/2314345#M85121</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-03-20T06:40:26Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] Use tJavaRow to get fieldname and fieldvalue</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-Use-tJavaRow-to-get-fieldname-and-fieldvalue/m-p/2314346#M85122</link>
      <description>Hello&amp;nbsp;
&lt;BR /&gt;The schema has been defined and they are fixed. I don't understand why you need to get the column name dynamically. To me, you can use a tJavaFlex component to loop each row and&amp;nbsp;concatenate each row to a string, for example:
&lt;BR /&gt;tFileInputXML--main--tJavaFlex
&lt;BR /&gt;in the begin part of tJavaFlex, define a empty string.&amp;nbsp;
&lt;BR /&gt;String result="";
&lt;BR /&gt;in the main part:
&lt;BR /&gt;Result=result+"CustomerID="+row1.CustomerID+","+"CustomerName="+row1.CustomerName+";";
&lt;BR /&gt;in the end part, print the result to console and put it to a global variable for used later.
&lt;BR /&gt;System.out.println(result);
&lt;BR /&gt;globalMap.put("key",result);
&lt;BR /&gt;Let me know if it fixes your need.
&lt;BR /&gt;Regards
&lt;BR /&gt;Shong</description>
      <pubDate>Tue, 21 Mar 2017 10:56:19 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-Use-tJavaRow-to-get-fieldname-and-fieldvalue/m-p/2314346#M85122</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-03-21T10:56:19Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] Use tJavaRow to get fieldname and fieldvalue</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-Use-tJavaRow-to-get-fieldname-and-fieldvalue/m-p/2314347#M85123</link>
      <description>Thanks Shong. But I knew of this option already. Even tJavaRow can do the same 
&lt;BR /&gt;I want to have a code I can re-use in all of my jobs. At the end of the day I'm going to have over 50 jobs with different input fields and field numbers. So the hardcoding of fieldnames in the javaflex code is not an ideal option for me. 
&lt;BR /&gt;The thing is there is a way to dynamically get the field names. But how do you dynamically get the field values in the same breath?</description>
      <pubDate>Tue, 21 Mar 2017 17:00:35 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-Use-tJavaRow-to-get-fieldname-and-fieldvalue/m-p/2314347#M85123</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-03-21T17:00:35Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] Use tJavaRow to get fieldname and fieldvalue</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-Use-tJavaRow-to-get-fieldname-and-fieldvalue/m-p/2314348#M85124</link>
      <description>Well in Enterprise version of Talend there is available Dynamic type schema, which is an object, whick you can query and it gives you dynamically any input structure (name of the fields) and you could iterate trough those and based on names obtain for each row the values. 
&lt;BR /&gt;In case your input message even with different columns is still the same (CSV file), it is not hard to write such java lib and forget about Talend tFileInputDelimited etc if you have only Open Source edition, you could use it as orchestrator only. 
&lt;BR /&gt;When this component obtain a key-value I suggest appending this into this structure - MultiMap ( 
&lt;A href="https://google.github.io/guava/releases/19.0/api/docs/com/google/common/collect/Multimap.html" target="_blank" rel="nofollow noopener noreferrer"&gt;https://google.github.io/guava/releases/19.0/api/docs/com/google/common/collect/Multimap.html&lt;/A&gt;)&amp;nbsp; 
&lt;BR /&gt;Then you can overide method .toString() or implement new one to print the data in the way you like. 
&lt;BR /&gt;If the insertion order is important, then go ahead with&amp;nbsp; 
&lt;A href="https://google.github.io/guava/releases/19.0/api/docs/com/google/common/collect/LinkedListMultimap.html" target="_blank" rel="nofollow noopener noreferrer"&gt;https://google.github.io/guava/releases/19.0/api/docs/com/google/common/collect/LinkedListMultimap.html&lt;/A&gt; 
&lt;BR /&gt;and that's it. I hope I understood your requirement correctly. 
&lt;BR /&gt;In general Talend won't help you in this case unless you have Enterprise edition and access to Dynamic schema, so do it by hand I suggest.</description>
      <pubDate>Fri, 24 Mar 2017 12:58:25 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-Use-tJavaRow-to-get-fieldname-and-fieldvalue/m-p/2314348#M85124</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-03-24T12:58:25Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] Use tJavaRow to get fieldname and fieldvalue</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-Use-tJavaRow-to-get-fieldname-and-fieldvalue/m-p/2314349#M85125</link>
      <description>Ok, based on communication we could do:&lt;BR /&gt;take output of tFileInputRead - tMap -&amp;gt; tJavaRow where you do:&lt;BR /&gt;iterate ({field}row.getDeclaredFields) {&lt;BR /&gt;field.getName()&lt;BR /&gt;switch field.getType()&lt;BR /&gt;case String: store String&lt;BR /&gt;case BigDecimal: convert and store to String&lt;BR /&gt;etc.&lt;BR /&gt;}&lt;BR /&gt;and here you go... &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Fri, 24 Mar 2017 16:31:15 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-Use-tJavaRow-to-get-fieldname-and-fieldvalue/m-p/2314349#M85125</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-03-24T16:31:15Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] Use tJavaRow to get fieldname and fieldvalue</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-Use-tJavaRow-to-get-fieldname-and-fieldvalue/m-p/2314350#M85126</link>
      <description>Thanks&amp;nbsp;
&lt;B&gt;&lt;FONT color="#5b5b5d"&gt;&lt;FONT size="2"&gt;&lt;FONT face="Verdana, Helvetica, Arial, sans-serif"&gt;archenroot&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/B&gt;&amp;nbsp;for all the assistance.&amp;nbsp;
&lt;BR /&gt;I got the output I was looking for using the code below:
&lt;BR /&gt;
&lt;PRE&gt;String columnName ="";&lt;BR /&gt;String fieldType = "";&lt;BR /&gt;String outString = "";&lt;BR /&gt;for (java.lang.reflect.Field field: tMapOut.getClass().getDeclaredFields()) {&amp;nbsp;&lt;BR /&gt;/*&lt;BR /&gt;tMapOut is the name connector from tMap to tJavaRow. Change to your map name&lt;BR /&gt;getDeclaredFields - to get the tmap output fields&lt;BR /&gt;*/&lt;BR /&gt;	columnName = field.getName();&lt;BR /&gt;	Class type = field.getType();&lt;BR /&gt;	String fieldValue = "";&lt;BR /&gt;	Object &amp;nbsp;objType = field.get(tMapOut);&amp;nbsp;&lt;BR /&gt;	switch (type.getSimpleName())&lt;BR /&gt;	{&lt;BR /&gt;	case "String": // Write as many cases as there are data types in your job. Convert each output to string using the respective methods&lt;BR /&gt;		fieldValue = (String)objType;&lt;BR /&gt;		break;&lt;BR /&gt;	case "Integer":&lt;BR /&gt;		fieldValue = String.valueOf((int)objType);&lt;BR /&gt;		break;&lt;BR /&gt;	case "BigDecimal":&lt;BR /&gt;		fieldValue = ((BigDecimal)objType).toPlainString();&lt;BR /&gt;	}&lt;BR /&gt;	outString += columnName + "=" + fieldValue + ",";&lt;BR /&gt;}&lt;BR /&gt;System.out.println(outString);&lt;BR /&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 26 Mar 2017 08:20:19 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-Use-tJavaRow-to-get-fieldname-and-fieldvalue/m-p/2314350#M85126</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-03-26T08:20:19Z</dc:date>
    </item>
  </channel>
</rss>

