Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Discover the Trends Shaping AI in 2026: Register Here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Vijay_K_N
Contributor
Contributor

Remove Duplicated from the record

I have source like this

record

11

1122

112233

11223344

i want output like 

record

1

12

123

1234

                           

 

Labels (2)
1 Solution

Accepted Solutions
Anonymous
Not applicable

Create a routine and add this function to transform it.
public static String removeDupsInPlace(String word) {
final StringBuilder output = new StringBuilder();

for (int i = 0; i < word.length(); i++) {
String character = word.substring(i, i + 1);
if (output.indexOf(character) < 0) // if not contained
output.append(character);
}
return output.toString();
}

Read the data as a string and pass it to the function.

Regards
Shong

View solution in original post

9 Replies
Anonymous
Not applicable

Create a routine and add this function to transform it.
public static String removeDupsInPlace(String word) {
final StringBuilder output = new StringBuilder();

for (int i = 0; i < word.length(); i++) {
String character = word.substring(i, i + 1);
if (output.indexOf(character) < 0) // if not contained
output.append(character);
}
return output.toString();
}

Read the data as a string and pass it to the function.

Regards
Shong
Vijay_K_N
Contributor
Contributor
Author

it showing the errors ,see in attachment 

 


error.PNG
uzix
Creator
Creator

hello,

 

you routine must be inside class

 

Vijay_K_N
Contributor
Contributor
Author

sorry i have zero knowledge in java can u clarify with screenshot

uzix
Creator
Creator

in talend 

see routine.jpg

-> code 

     -> routines 

                --> "create new "

 

name it whatever you want

in my case is "test"

inside class "test"

paste the function that @shong as made available to you_:

see routine2.jpg

 

you can use your function in a tjavarow .

example:

if data source is file , and you want to use the function in 3 cloumns of input data source:

see routine3.jpg

the ouptut will be the value of input data transformed by the function.

 

 


routine3.jpg
routine2.jpg
routine.jpg
akumar2301
Specialist II
Specialist II



Array.from(new Set(yourString)).join('')

If Array class not available try below regex

yourString.replace(/(.)(?=.*\1)/g, "")



Vijay_K_N
Contributor
Contributor
Author

Thanks for ur reply...its working

Vijay_K_N
Contributor
Contributor
Author

thanks for ur neat explanation 

Vijay_K_N
Contributor
Contributor
Author

i dont have knowledge on regular expressions bro