Skip to main content
Announcements
Introducing a new Enhanced File Management feature in Qlik Cloud! GET THE DETAILS!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Split

Hello,

I have this text:

25.815.53.6

And I need to get:

25.8
15.5
3.6

Or this text:

22.816.210.2

And I want to get:

22.8
16.2
10.2

Thank you very much.

Labels (2)
1 Reply
Anonymous
Not applicable
Author

I have had to guess at your requirement here. I guessed the following....

1) Every number will have a decimal point

2) Every decimal point will be followed by 1 decimal digit

 

If those guesses are correct, this code will work in a tJava....

 

String foo = "25.815.53.622.816.210.2";

while(foo.indexOf('.')>-1){
	int position = foo.indexOf('.')+2;
	String value = foo.substring(0,position);
	foo = foo.substring(position);
	System.out.println(value);
}

Next, you need to convert your data into rows. This can be done using a tJavaFlex. I will assume that you can get the data into a globalMap variable. If not, look at the tSetGlobalVar or tFlowToIterate components. Once your data is in a globalMap variable, you can use the following code with your tJavaFlex....

 

Start Code

String data = ((String)globalMap.get("mydata"));
while(data.indexOf('.')>-1){

Main Code

int position = data.indexOf('.')+2;
row1.value = data.substring(0,position);
data = data.substring(position);

End Code

}

This will output your data in separate rows.