Customer Portal

Variable length records

Comments 2

  • Avatar
    avackova
    0
    Comment actions Permalink
    It is not possible to do it in one step. You have to read all data (one field with eol delimiter or mixed metadata) and then partition them. After partitioning you can write them to different files (and they are prepared for reading now) or validate in Reformat or Filter node.
  • Avatar
    avackova
    0
    Comment actions Permalink
    Hello,
    since 2.5 ver. you can use Reformat component with following transform function:
    function transform() {
    string f4 = null;
    string f5 = null;
    string f6 = null;
    string f7 = null;
    int recType;
    list tmp = split($field3,' ');
    if (char_at($Field1,0).eq.'H') recType = 0;
    else if (char_at($Field1,0).eq.'D') recType=1;
    else recType = 2;
    if (length(tmp) > 1) f4 = tmp[1];
    if (length(tmp) > 2) f5 = tmp[2];
    if (length(tmp) > 3) f6 = tmp[3];
    if (length(tmp) > 4) f7 = tmp[4];
    $0.field1 := $0.Field1;
    $1.field1 := $0.Field1;
    $2.field1 := $0.Field1;
    $0.field2 := $0.field2;
    $1.field2 := $0.field2;
    $2.field2 := $0.field2;
    $0.field3 := tmp[0];
    $1.field3 := tmp[0];
    $2.field3 := tmp[0];
    $0.field4 := f4;
    $1.field4 := f4;
    $1.field5 := f5;
    $1.field6 := f6;
    $1.field7 := f7;
    return recType
    }

Please sign in to leave a comment.