Posts

Showing posts with the label Normalize Component

S) Normalise scenario --> Input: 1,a,b,c,2,d,e,f,g

 Input: 1,a,b,c,2,d,e,f,g   Output: field1 field2 1       a 1       b 1       c 2       d 2       e 2       f 2       g     input---->normalize--->output   type temporary_type =  record   decimal("") v_col1;   decimal("") v_col2; end; out::length(in) = begin   out :: length_of(string_split(in.col, ",")); end; temp::normalize(temp, in, index) = begin   temp.v_col1 :: if (string_is_numeric(string_split(in.col, ",")[index])==1)                      string_split(in.col, ",")[index] else temp.v_col1;   temp.v_col2 :: string_split(in.col, ",")[index]; end; temp::initialize(in) = begin   temp.v_col1 :: 0;   temp.v_col2 :: 0; end; out::finalize(temp, in) = begin   out.col1 :: temp.v_col1;   out.col2 :: temp.v_col2; end; ...

S) Reformat and normalize example -- Input : 1,2,3-7,8,9

Image
 Input : 1,2,3-7,8,9 Output : 1 2 3 4 5 6 7 8 9  Solution  let decimal ( 4)val 1 =0;   let decimal ( 4)val 2 =0;   let decimal ( 4)diff =0;     out:: reformat(in)=   begin   if ( string_index (in.id, "-" ))           begin           val1 = string_substring ( string_replace ( string_substring (in.id, 1,string _index(in.id, "-" )-1), "," , " " ),1,1);           val2= string_substring ( string_replace ( string_substring ( in.id,string_index (in.id, "-" )+ 1,string _length(in.id)), "," , "" ),3,1);           diff =(val2-val 1)+ 1;           end     else diff =1;     out.id : : if ( string_index (in.id, "-" )> 0) val 1  else in.id;     out.diff :: diff;     end ;   Normalize   out:: len...