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

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
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
Highlighted
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.

Calling Talend Open Studio Users

The first 100 community members completing the Open Studio survey win a $10 gift voucher.

Start the survey

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog

How Media Organizations Achieved Success with Data Integration

Learn how media organizations have achieved success with Data Integration

Read

Definitive Guide to Data Quality

Create systems and workflow to manage clean data ingestion and data transformation.

Download