#!/usr/bin/awk # ajoute des valeurs manquantes # à une base au format attribut-valeur BEGIN{ if(ARGC != 4){ print "# ajoute des valeurs manquantes a une base au format attribut-valeur"; print ARGV[0] ": usage <% missing values> [data]"; exit; } startcol = ARGV[1]; prop = ARGV[2] / 100; # print "# adding " prop * 100 " % of random missing values starting from column " startcol " on " ARGV[3]; ARGV[1] = ARGV[3]; ARGC = 2; srand(0); FS = ","; OFS = "," } /\#/ { print $0; next; } { for(i = 1; i < NF; i ++){ if(i >= startcol && rand() < prop) printf("?," ); else printf("%s,", $i); } if(rand() < prop) printf("?" ); else printf("%s", $NF); printf("\n"); }