NR==1 {n=split(Some,Tmp,/\n/); for(I=1;I<=n;I++) { Wanted[++Wanted[0]]= Tmp[I] Index[Tmp[I]]=Tmp[I] } } {sub(/%.*/,"")} /^[ \t]$/ {next} /@data/ {FS=","; attributes(); print $0} /@relation/ {print $0} /@attribute/ {N++} /@attribute/ && ($2 == "loc") {Locs++; if (Locs > 1) next} /@attribute/ && ($2 in Index) {At[$2]=N; About[$2]=$0} /@/ {next} $NF == "yes" {$NF="true" } $NF == "no" {$NF="false"} NF > 10 { str=sep="" max=Wanted[0] for(i=1;i<=max;i++) { str = str sep $At[Wanted[i]] ; sep = "," } print str } function attributes() { max=Wanted[0]; for(i=1;i<=max;i++) print About[Wanted[i]] }