One Star

How to normalize a List to single String(see Example)

Example:
I have a schema with id(String) and letters(List), and want to normalize this into key/letter.
From:
Row number id(String) letters(List)
1 k1
2 k2
to:

Row number id(String) letters(List)
1 k1 a
2 k1 b
3 k1 d
4 k2 b
5 k2 d
6 k2 g
Any component that do this ?
Audun
6 REPLIES
One Star

Re: How to normalize a List to single String(see Example)

Hi,
You can use tNormalize component for this job.
--
Regards,
Vinod
One Star

Re: How to normalize a List to single String(see Example)

Hi,
You can use tNormalize component for this job.
--
Regards,
Vinod

Can´t, tNormalize works on String not List.
regards
Audun
One Star

Re: How to normalize a List to single String(see Example)

Before applying tNormalize on the field you can convert the data type using tConvertType or by using toString() in tJavaRow .
One Star

Re: How to normalize a List to single String(see Example)

Hi,
You can use below mentioned graph and code as sample.
Job Map
-----------
tFileInputDelimited --> tJavaRow --> tNormalize --> tLogRow
tFileInputDelimited Input
-------------------------
id;letters
k1;a,b,c
k2;d,e,f
tJavaRow code
--------------------
output_row.id = input_row.id;
output_row.letters = input_row.letters.toString().replace("", "");
Hope that helps.
--
Regards,
Vinod
One Star

Re: How to normalize a List to single String(see Example)

Hi,
You can use below mentioned graph and code as sample.
Job Map
-----------
tFileInputDelimited --> tJavaRow --> tNormalize --> tLogRow
tFileInputDelimited Input
-------------------------
id;letters
k1;a,b,c
k2;d,e,f
tJavaRow code
--------------------
output_row.id = input_row.id;
output_row.letters = input_row.letters.toString().replace("", "");
Hope that helps.
--
Regards,
Vinod

Why convert a List to String before creating a Array ? It will create bigger memory footprint. tNormalize should support List normalize.
One Star

Re: How to normalize a List to single String(see Example)

Why not define letters as a string in your schema.