Four Stars

Conditional Schema


I am absolutely new to Talend and having a hard time figuring out how to parse a file whose layout changes based on a certain identifier.

in the example below schema/layout for RCID through RECORD_KEY does not vary but anything after that can vary based on the value of RCID

string(2) RCID ;  ------ Fixed
string(1) CDGT ; ------ Fixed
string(1) TCND ; ------ Fixed

string(5) RECORD_KEY; ------ Fixed

if (RCID=="01") 

string(4) TRNC;
string(4) FILL1;

if (RCID=="02") 

string(6) PCTY;
string(8) DPCR;

if (RCID == "03")
string(5) ORAC;
string(5) DSTC;


Raw data: 





Records in the input file may or may not be in the sorted order. In the example above RCID "02" appears before RCID "03". Please note record types 01-through 03 are part of the same record having the same key value "12345". I need to read the file and later aggregate it based on this key. Any ideas? I have searched this forum but did not find anything meaningful.

Does Talend allow Nested Schema definition? For example, if in the same group of records, if I want to say in TMPA that if it record type 01 then do this else if it is record type 02 then do this.




Seven Stars

Re: Conditional Schema


In tMap component, there is expression filter and with help of this filter you can define which branch should be used to process the record. Please reed about it here:
As I understand "RCID" depends on the length of the string, so in the expression filter you will evaluate the length of the string as a condition for the branch.
Hope it helps.