<?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: Searching distincrt elements in a line in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/Searching-distincrt-elements-in-a-line/m-p/2221958#M15751</link>
    <description>&lt;P&gt;Nice solution&amp;nbsp;&lt;A href="https://community.qlik.com/s/profile/0053p000007LNJ9AAO"&gt;@uzix&lt;/A&gt;, but it might be a bit more tempting for someone to use if you provided the code to be copied &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt; Would you mind sharing the code as text to make this easy for people?&lt;/P&gt;</description>
    <pubDate>Mon, 02 Mar 2020 21:30:26 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2020-03-02T21:30:26Z</dc:date>
    <item>
      <title>Searching distincrt elements in a line</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Searching-distincrt-elements-in-a-line/m-p/2221955#M15748</link>
      <description>&lt;P&gt;Hello evryone,&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;I need your help.&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;I have a csv file with this 3 lines :&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;a;b;b;c;d;d;v;a;g&lt;BR /&gt;f;f;a;g;a;g;h;p&lt;BR /&gt;a;a;a;a;a;a;a;b&lt;/P&gt; 
&lt;P&gt;As a result, i would like to have a distinct lines :&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;a;b;c;d;v;g&lt;/P&gt; 
&lt;P&gt;f;a;g;h;p&lt;/P&gt; 
&lt;P&gt;a;b&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Thanks for your contribution &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;&lt;/P&gt;</description>
      <pubDate>Sun, 01 Mar 2020 13:15:39 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Searching-distincrt-elements-in-a-line/m-p/2221955#M15748</guid>
      <dc:creator>trimech</dc:creator>
      <dc:date>2020-03-01T13:15:39Z</dc:date>
    </item>
    <item>
      <title>Re: Searching distincrt elements in a line</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Searching-distincrt-elements-in-a-line/m-p/2221956#M15749</link>
      <description>&lt;P&gt;This is an interesting requirement as you are essentially asking to treat columns in a similar way to which you would treat rows. However, I have knocked up a quick example that appears to work. It will limit occurrences of strings to once per row and will sort them alphabetically. A screenshot of the job can be seen below.....&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2020-03-02 at 13.54.17.png" style="width: 999px;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009M9E4.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/146493i9BC94C9A2FC1410E/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009M9E4.png" alt="0683p000009M9E4.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;The bit you need to look at is the code in the tJavaFlex. Pay attention to the fact that I have used default column names and I have unticked the "Data Auto Propagate" option. The code is in the Main Code section and looks like this.....&lt;/P&gt; 
&lt;PRE&gt;//Code generated according to input schema and output schema
String[] list = new String[9];

list[0] = row1.newColumn;
list[1] = row1.newColumn1;
list[2] = row1.newColumn2;
list[3] = row1.newColumn3;
list[4] = row1.newColumn4;
list[5] = row1.newColumn5;
list[6] = row1.newColumn6;
list[7] = row1.newColumn7;
list[8] = row1.newColumn8;

for(int i = 0; i&amp;lt;9; i++){
	for(int x = 0; x&amp;lt;9; x++){
		if(list[i].equals(list[x]) &amp;amp;&amp;amp; i!=x){
			list[i]="";
		}
	}

}

//Sort array alphabetically
List&amp;lt;String&amp;gt; storedValues = java.util.Arrays.asList(list);
java.util.Collections.sort(storedValues);

//Return values to original array
list = storedValues.toArray(list);

//Remove empty Strings from array
String[] cleaned_list = new String[9];

int pos = 0;

for(int i=0; i&amp;lt;list.length;i++){
	if(!list[i].equals("")){
		cleaned_list[pos] = list[i];
		pos++;
	}

}


//Assign ordered, distinct values
row2.newColumn = cleaned_list[0];
row2.newColumn1 = cleaned_list[1];
row2.newColumn2 = cleaned_list[2];
row2.newColumn3 = cleaned_list[3];
row2.newColumn4 = cleaned_list[4];
row2.newColumn5 = cleaned_list[5];
row2.newColumn6 = cleaned_list[6];
row2.newColumn7 = cleaned_list[7];
row2.newColumn8 = cleaned_list[8];
&lt;/PRE&gt; 
&lt;P&gt;The input data I used was as follows....&lt;/P&gt; 
&lt;PRE&gt;a;b;b;c;d;d;v;a;g
f;f;a;g;a;g;h;p
a;a;a;a;a;a;a;b&lt;/PRE&gt; 
&lt;P&gt;....the data returned looked like this....&lt;/P&gt; 
&lt;PRE&gt;a|b|c|d|g|v|||
a|f|g|h|p||||
a|b|||||||&lt;/PRE&gt;</description>
      <pubDate>Mon, 02 Mar 2020 13:59:29 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Searching-distincrt-elements-in-a-line/m-p/2221956#M15749</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-03-02T13:59:29Z</dc:date>
    </item>
    <item>
      <title>Re: Searching distincrt elements in a line</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Searching-distincrt-elements-in-a-line/m-p/2221957#M15750</link>
      <description>&lt;P&gt;hello,&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;indeed as&amp;nbsp;&lt;A href="https://community.qlik.com/s/profile/005390000069RuGAAU"&gt;@rhall&lt;/A&gt;&amp;nbsp; said is an interesting requirement , i present an alternate solution.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;i use a tFileInputFullRow as source for the file with the 3 lines.&lt;/P&gt; 
&lt;P&gt;connect to a tjavarow - hip1.jpg&lt;/P&gt; 
&lt;P&gt;use function as in hip2.jpg -&amp;gt; function provided by&amp;nbsp;&lt;A href="https://community.qlik.com/s/profile/00539000004XsnJAAS"&gt;@shong&lt;/A&gt;&amp;nbsp; in previous example to hadle duplicate data in string with a small tweak from me.&lt;/P&gt; 
&lt;P&gt;[statistics] connected&lt;BR /&gt;.-----------------.&lt;BR /&gt;| logIinput |&lt;BR /&gt;|=---------------=|&lt;BR /&gt;|line |&lt;BR /&gt;|=---------------=|&lt;BR /&gt;|a;b;b;c;d;d;v;a;g|&lt;BR /&gt;|f;f;a;g;a;g;h;p |&lt;BR /&gt;|a;a;a;a;a;a;a;b |&lt;BR /&gt;'-----------------'&lt;/P&gt; 
&lt;P&gt;.-----------.&lt;BR /&gt;| logoutput |&lt;BR /&gt;|=---------=|&lt;BR /&gt;|line |&lt;BR /&gt;|=---------=|&lt;BR /&gt;|a;b;c;d;g;v|&lt;BR /&gt;|a;f;g;h;p |&lt;BR /&gt;|a;b |&lt;BR /&gt;'-----------'&lt;/P&gt; 
&lt;P&gt;[statistics] disconnected&lt;/P&gt;&lt;BR /&gt;&lt;A href="https://community.qlik.com/legacyfs/online/tlnd_dw_files/0683p000009Lxdq"&gt;hip2.jpg&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://community.qlik.com/legacyfs/online/tlnd_dw_files/0683p000009LxB4"&gt;hip1.jpg&lt;/A&gt;</description>
      <pubDate>Mon, 02 Mar 2020 15:13:02 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Searching-distincrt-elements-in-a-line/m-p/2221957#M15750</guid>
      <dc:creator>uzix</dc:creator>
      <dc:date>2020-03-02T15:13:02Z</dc:date>
    </item>
    <item>
      <title>Re: Searching distincrt elements in a line</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Searching-distincrt-elements-in-a-line/m-p/2221958#M15751</link>
      <description>&lt;P&gt;Nice solution&amp;nbsp;&lt;A href="https://community.qlik.com/s/profile/0053p000007LNJ9AAO"&gt;@uzix&lt;/A&gt;, but it might be a bit more tempting for someone to use if you provided the code to be copied &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt; Would you mind sharing the code as text to make this easy for people?&lt;/P&gt;</description>
      <pubDate>Mon, 02 Mar 2020 21:30:26 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Searching-distincrt-elements-in-a-line/m-p/2221958#M15751</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-03-02T21:30:26Z</dc:date>
    </item>
    <item>
      <title>Re: Searching distincrt elements in a line</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Searching-distincrt-elements-in-a-line/m-p/2221959#M15752</link>
      <description>&lt;P&gt;hello&amp;nbsp;&amp;nbsp;&lt;A href="https://community.qlik.com/s/profile/005390000069RuGAAU"&gt;@rhall&lt;/A&gt;&amp;nbsp;, sure here goes:&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;i just adapted code provided by&amp;nbsp;&lt;A href="https://community.qlik.com/s/profile/00539000004XsnJAAS"&gt;@shong&lt;/A&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;PRE&gt;public static String removeDupsInPlace(String word) {
final StringBuilder output = new StringBuilder();
String wordSorted = "";
String output_a ="";
char tempArray[] = word.replaceAll(";","").toCharArray();
// sort tempArray
Arrays.sort(tempArray);
wordSorted = new String(tempArray);
for (int i = 0; i &amp;lt; wordSorted.length(); i++)
{
String character = wordSorted.substring(i, i + 1);
if (output.indexOf(character) &amp;lt; 0 ) // if not contained
//output.append(character);
output.append(character).append(";");
}
//remove ; if last char
if(output.toString().endsWith(";"))
{
output_a = output.toString().substring(0,output.length() - 1);
}else{&lt;BR /&gt;output_a = output.toString();&lt;BR /&gt;}
return output_a;
}&lt;/PRE&gt;</description>
      <pubDate>Tue, 03 Mar 2020 08:51:46 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Searching-distincrt-elements-in-a-line/m-p/2221959#M15752</guid>
      <dc:creator>uzix</dc:creator>
      <dc:date>2020-03-03T08:51:46Z</dc:date>
    </item>
    <item>
      <title>Re: Searching distincrt elements in a line</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Searching-distincrt-elements-in-a-line/m-p/2221960#M15753</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;A href="https://community.qlik.com/s/profile/0053p000007LNJ9AAO"&gt;@uzix&lt;/A&gt;. It makes it so much easier when you can copy and paste code &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Mar 2020 10:11:09 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Searching-distincrt-elements-in-a-line/m-p/2221960#M15753</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-03-03T10:11:09Z</dc:date>
    </item>
  </channel>
</rss>

