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: 
sbxr
Contributor III
Contributor III

One coloum having same delimiter how to load that data

I Have data which is in below format and output should be as mentioned output below:

 

Input:

id | Feedback | xml

1 | its ok | go | test_xml

 

its ok | go this is the one value of data..Pipe delimiter should be there in the delimiter

mysqlOutput:

id | Feedback | xml

1 | its ok | go | test_xml

 

Labels (2)
1 Solution

Accepted Solutions
Anonymous
Not applicable

Do you have any control over the system giving you this file? The reason I ask is that this is potentially a really hard problem to solve and get right. It would be good to have something indicating a text block. However, this example is relatively simple. You know that the first column is going to be a number. So the first pipe after a number is definitely a separator. You also know that the last column is a value ending with "xml". So the pipe before that is definitely a separator.

 

This could be achieved by bringing the whole row in one column, then using a tJavaFlex to apply the rules above to that column. Alternatively, you could use this simple logic which i have just thought of. 

 

String value = row1.inputValue;

String[] parts = value.split("\\|");
int sections = parts.length;

row2.column1 = parts[0];
String column2 = "";

for(int i=1;i<sections-1;i++){
	column2=column2+parts[i];
}

row2.column2 = column2;
row2column3 = parts[sections-1];

This would be carried out in the Main Code of a tJavaFlex.

Your input row would be called row1. The column on that row would be called inputValue.

You split the values into a String array by using the pipe.

The very first value is your first column. The very last value is your last column. The values in the middle are joined together to make your middle column. You would lose the pipe in the middle of the middle column doing this though.

View solution in original post

1 Reply
Anonymous
Not applicable

Do you have any control over the system giving you this file? The reason I ask is that this is potentially a really hard problem to solve and get right. It would be good to have something indicating a text block. However, this example is relatively simple. You know that the first column is going to be a number. So the first pipe after a number is definitely a separator. You also know that the last column is a value ending with "xml". So the pipe before that is definitely a separator.

 

This could be achieved by bringing the whole row in one column, then using a tJavaFlex to apply the rules above to that column. Alternatively, you could use this simple logic which i have just thought of. 

 

String value = row1.inputValue;

String[] parts = value.split("\\|");
int sections = parts.length;

row2.column1 = parts[0];
String column2 = "";

for(int i=1;i<sections-1;i++){
	column2=column2+parts[i];
}

row2.column2 = column2;
row2column3 = parts[sections-1];

This would be carried out in the Main Code of a tJavaFlex.

Your input row would be called row1. The column on that row would be called inputValue.

You split the values into a String array by using the pipe.

The very first value is your first column. The very last value is your last column. The values in the middle are joined together to make your middle column. You would lose the pipe in the middle of the middle column doing this though.