Tnormalize for multi columns

Five Stars

Tnormalize for multi columns

Hello,

 

Result:

column1 | column 2 | column 3 | column

1,2,3,4,5 | a,s,d,f,g | z,x,c,v,d | q,w,e,r,t

 

I want to this :

 

column1 | column 2 | column 3 | colum

1             | a             |z               |q

2             | s             |x               |w

 

How can i do this ?There is have too many topic about this issue but i can't fix this.

 

 


Accepted Solutions
Ten Stars

Re: Tnormalize for multi columns

If you want to elaborate your case (with details about your input data, particularly), we may be able to offer further assistance.


All Replies
Ten Stars

Re: Tnormalize for multi columns

This can probably be done with tMap variables or multiple tNormalize components where you filter out rows based on a sequencer value.  The simplest solution I came up with is to use tNormalize on the first column to get break out the list of keys, then use a tJavaRow to build a String array for each letter column.  Using the key to index the array gets you the corresponding value from the list.

 

tFileInputDelimited --> tNormalize --> tJavaRow --> tLogRow

 

Schema: key, col1, col2, col3 (all strings)

 

tJavaRow code:

String[] values1 = input_row.col1.split(",");
String[] values2 = input_row.col2.split(",");
String[] values3 = input_row.col3.split(",");
int index = Integer.parseInt(input_row.key) - 1;

output_row.key = input_row.key;
output_row.col1 = values1[index];
output_row.col2 = values2[index];
output_row.col3 = values3[index];

Output:

[statistics] connecting to socket on port 3982
[statistics] connected
1|a|z|q
2|s|x|w
3|d|c|e
4|f|v|r
5|g|d|t
[statistics] disconnected
Five Stars

Re: Tnormalize for multi columns

 

Hello,

Thanks for help.Yes i did it but its have problem on me.I cant do this.Its giving error after to 1 row.(1 row coming to tjava but after than its giving error).Error = nullpointerexception.Its can be about my design ?

 

Twebservice > tnormalize(Key selected) > tjavarow > tfileoutputexcel

TJavarow:

//Code generated according to input schema and output schema
String[] title = input_row.title.split(",");
String[] subtitle = input_row.subtitle.split(",");
int index = Integer.parseInt(input_row.id) - 1;

output_row.id = input_row.id;
output_row.title = title[index];
output_row.subtitle = subtitle[index];

I am getting data from twebservice.Other column data types integer and i can't use them with "split".Sorry its my fault.I sent you missing information.

 

Ten Stars

Re: Tnormalize for multi columns

If you want to elaborate your case (with details about your input data, particularly), we may be able to offer further assistance.

Five Stars

Re: Tnormalize for multi columns

Hello,

 

Data types is too much.I have 20-30 column.Input data is xml tree but its not xml.

 

Input is twebservice.Input data coming from api.Every column data is example in below:

 

Column1(name) : "[asad,saewq,asdasd,asdad,asdad,asdas]"

......

column30Smiley Sadprice) : "[1,2,3,4,5,6]"

 

I guess your first tjava sample giving error because i need to filter "[" and "]"

I matched index variable with "id" column but first data coming with same this "[1231231312"

and last data "123123123]"Its giving error because "[" << this value.

 

Except this:

Can you offer me another road ?I added 1 image and 2 xml file.

Image for twebservice connection screen.

out.xml = only one row

out2.xml = its two row