Customer Portal

Normalising sparse data - best method?

Comments 2

  • Avatar
    dpavlis
    0
    Comment actions Permalink
    Hi,
    it is a bit tricky... if you want to account for all possible variations/missing values. But following example might help you:


    function integer transform() {
    map[string,string] values; //map for holding your "sparse" data
    string[] pairs = split($in.0.data,"\\^"); //split input string into key-value pairs

    //iterate and create real keys&values
    foreach(string pair : pairs){
    string[] def=split(pair,"=");
    values[def[0]]=def[1]:null; //if there is no value for key, insert null as a key's value
    }

    printLog(info,values); //just DEBUG print

    $out.0.modified = str2date(nvl(values["dataizd"],"01.01.1970" ), "dd.MM.yyyy"); //if there is no dataizd value or key does not exist at all, use default value
    $out.0.link_ref = str2integer(nvl(values["kolon], "0"));
    ///.... other assignments....

    return ALL;
    }
  • Avatar
    sadler
    0
    Comment actions Permalink
    Thank you very much. :D

Please sign in to leave a comment.