# input1: the input data # input2: the rules to be applied for erasing some values # out: the data with missing values # replaces the conclusion of the rule with the maximal item + 1 # introduces new values # preserves the first column BEGIN{ if (ARGC != 3){ print "error usage: " ARGV[0] " "; exit(1); } rule = ARGV[2]; ARGC -= 1; while ((getline line < rule) > 0){ # decode a line such as 37 , 7 : 14 = 7 32 45 49 51 65 66 85 141 187 226 230 247 269 split(line, tab1, " = "); split(tab1[1], tab2, " , "); split(tab2[2], tab3, " : "); targets = tab3[1] split(tab1[2], lines, " "); # create the table of lines containing the concatenation of all targets for (l in lines) tab[lines[l]] = tab[lines[l]] " " targets } } { printf("%d", $1); for (i = 2; i <= NF; i ++){ if (NR in tab){ split(tab[NR], targ, " ") for (t in targ) if (targ[t] == $i) break; if (targ[t] == $i) printf(",?") else printf(",%d", $i); }else printf(",%d", $i); } printf("\n"); }