Formata o número de pontos decimais

0

Eu quero dividir a quinta coluna em três casas decimais e colocá-la na primeira coluna.

Entrada

                 Accuracy Precision Recall F-measure      s.d
 bemkl_J_DIFP    0.6001   0.01545 0.4304   0.02984    0.016098
 bemkl_J_DI      0.6011   0.01390 0.3870   0.02684    0.013959
 bemkl_J_FP      0.4831   0.01424 0.3609   0.02740    0.015979

OutputFile

                 Accuracy      Precision Recall   F-measure
bemkl_J_DIFP  0.6001(0.016)     0.01545   0.4304   0.02984
bemkl_J_DI    0.6011(0.013)     0.01390   0.3870   0.02684
bemkl_J_FP    0.4831(0.015)     0.01424   0.3609   0.02740

Comando:

awk -F" " '$6>0 { print substr($6,1,5)}' filename| awk '{print "("$0")"}'
    
por KHAN irfan 10.10.2017 / 02:42

1 resposta

1
$ cat 1.awk
BEGIN { FS = " " ; }
NR == 1  { printf "%26s %16s %8s %11s\n", $1, $2, $3, $4 }
NR > 1   { printf "%-15s %s(%0.2g)      %s    %s    %s\n", $1, $2, $6, $3, $4, $5 }
$ awk -f 1.awk infile
                  Accuracy        Precision   Recall   F-measure
bemkl_J_DIFP    0.6001(0.016)      0.01545    0.4304    0.02984
bemkl_J_DI      0.6011(0.014)      0.01390    0.3870    0.02684
bemkl_J_FP      0.4831(0.016)      0.01424    0.3609    0.02740
    
por 10.10.2017 / 05:35