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

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
rp2018
Creator
Creator

tJavaRow to split string

I have a following string which I need to split based on 2 delimiters. Will be using tJavaRow to split this.

["Test Company, Inc.","Test Company (Test) LLC","VM (Test), LLC","JK (Test), LLC"]

Need result such as:

Test Company, Inc.

Test Company (Test) LLC

VM (Test), LLC

JK (Test), LLC

Labels (3)
1 Solution

Accepted Solutions
Anonymous
Not applicable

Process separately Value and Label using the way I provided in my previous post.

Next, add a sequence id to each row, eg:

Numberic.sequence("value",1,1)

Finally, do an inner join based on sequence id to merge two columns Value and Label.

 

Regards

Shong

View solution in original post

4 Replies
Anonymous
Not applicable

Hi

First, remove the square brackets "[","]" from the string on a tJavaRow.

0695b00000L2g1YAAR.pngThen, use tNormalize to normlize the line to multiple rows using item seperator "\","

0695b00000L2g2RAAR.png 

Finally, remove the double quotes from each value on a tJavaRow2.

output_row.line = input_row.line.replaceAll("\"","");

 

Result:

Starting job testing at 11:06 01/12/2021.

[statistics] connecting to socket on port 3346

[statistics] connected

Test Company, Inc.

Test Company (Test) LLC

VM (Test), LLC

JK (Test), LLC

[statistics] disconnected

 

Job testing ended at 11:06 01/12/2021. [Exit code = 0]

 

Regards

Shong

 

 

rp2018
Creator
Creator
Author

Thanks Shong for the above solution.

 

I have another column which contains a picklist id which needs to be associated to this. I've tried adjusting your code to get the result, 

but no success.

 

|Value        |Label                                                                                                                                                

|=------------------------------------------------------------------------------------------+----

|[1000,1002,2200,3400]|["Test Company, Inc.","Test Company (Test) LLC","VM (Test), LLC","JK (Test), LLC"]

-------------------------------------------------------------------------------------------+-----

 

Need result such as this in 2 separate columns:

 

Value Label

1000 Test Company, Inc.

1002 Test Company (Test) LLC

2200 VM (Test), LLC

3400 JK (Test), LLC

Anonymous
Not applicable

Process separately Value and Label using the way I provided in my previous post.

Next, add a sequence id to each row, eg:

Numberic.sequence("value",1,1)

Finally, do an inner join based on sequence id to merge two columns Value and Label.

 

Regards

Shong

rp2018
Creator
Creator
Author

Shong, your recommendation worked with little twick of using tReplace component.

For others reference, this is how I've designed the job.

0695b00000Lx5F8AAJ.pngInput file:

0695b00000Lx5HsAAJ.png0695b00000Lx5FXAAZ.png0695b00000Lx5G1AAJ.png0695b00000Lx5GGAAZ.png0695b00000Lx5GQAAZ.png0695b00000Lx5GfAAJ.png0695b00000Lx5H4AAJ.png0695b00000Lx5H9AAJ.png