Format the number of decimal points
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I want to slice the 5th column down to three decimal points and put it with first column.
Input
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
Command:
awk -F" " '$6>0 print substr($6,1,5)' filename| awk 'print "("$0")"'
shell-script text-formatting numeric-data
add a comment |Â
up vote
0
down vote
favorite
I want to slice the 5th column down to three decimal points and put it with first column.
Input
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
Command:
awk -F" " '$6>0 print substr($6,1,5)' filename| awk 'print "("$0")"'
shell-script text-formatting numeric-data
awk -F" " '$6>0 print substr($6,1,5)' filename
â KHAN irfan
Oct 10 '17 at 0:59
As you're using AWK in your comment, note thatprintf "%.3f", $6
actually cuts the field down to three decimal places, regardless of how many digits are before the point, unlikesubstr
â Fox
Oct 10 '17 at 1:17
I think you mean the 6th column - not the 5th column
â fpmurphy1
Oct 10 '17 at 3:04
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I want to slice the 5th column down to three decimal points and put it with first column.
Input
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
Command:
awk -F" " '$6>0 print substr($6,1,5)' filename| awk 'print "("$0")"'
shell-script text-formatting numeric-data
I want to slice the 5th column down to three decimal points and put it with first column.
Input
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
Command:
awk -F" " '$6>0 print substr($6,1,5)' filename| awk 'print "("$0")"'
shell-script text-formatting numeric-data
shell-script text-formatting numeric-data
edited Oct 10 '17 at 23:38
asked Oct 10 '17 at 0:42
KHAN irfan
83
83
awk -F" " '$6>0 print substr($6,1,5)' filename
â KHAN irfan
Oct 10 '17 at 0:59
As you're using AWK in your comment, note thatprintf "%.3f", $6
actually cuts the field down to three decimal places, regardless of how many digits are before the point, unlikesubstr
â Fox
Oct 10 '17 at 1:17
I think you mean the 6th column - not the 5th column
â fpmurphy1
Oct 10 '17 at 3:04
add a comment |Â
awk -F" " '$6>0 print substr($6,1,5)' filename
â KHAN irfan
Oct 10 '17 at 0:59
As you're using AWK in your comment, note thatprintf "%.3f", $6
actually cuts the field down to three decimal places, regardless of how many digits are before the point, unlikesubstr
â Fox
Oct 10 '17 at 1:17
I think you mean the 6th column - not the 5th column
â fpmurphy1
Oct 10 '17 at 3:04
awk -F" " '$6>0 print substr($6,1,5)' filename
â KHAN irfan
Oct 10 '17 at 0:59
awk -F" " '$6>0 print substr($6,1,5)' filename
â KHAN irfan
Oct 10 '17 at 0:59
As you're using AWK in your comment, note that
printf "%.3f", $6
actually cuts the field down to three decimal places, regardless of how many digits are before the point, unlike substr
â Fox
Oct 10 '17 at 1:17
As you're using AWK in your comment, note that
printf "%.3f", $6
actually cuts the field down to three decimal places, regardless of how many digits are before the point, unlike substr
â Fox
Oct 10 '17 at 1:17
I think you mean the 6th column - not the 5th column
â fpmurphy1
Oct 10 '17 at 3:04
I think you mean the 6th column - not the 5th column
â fpmurphy1
Oct 10 '17 at 3:04
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
$ cat 1.awk
BEGIN FS = " " ;
NR == 1 printf "%26s %16s %8s %11sn", $1, $2, $3, $4
NR > 1 printf "%-15s %s(%0.2g) %s %s %sn", $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
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
$ cat 1.awk
BEGIN FS = " " ;
NR == 1 printf "%26s %16s %8s %11sn", $1, $2, $3, $4
NR > 1 printf "%-15s %s(%0.2g) %s %s %sn", $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
add a comment |Â
up vote
1
down vote
accepted
$ cat 1.awk
BEGIN FS = " " ;
NR == 1 printf "%26s %16s %8s %11sn", $1, $2, $3, $4
NR > 1 printf "%-15s %s(%0.2g) %s %s %sn", $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
add a comment |Â
up vote
1
down vote
accepted
up vote
1
down vote
accepted
$ cat 1.awk
BEGIN FS = " " ;
NR == 1 printf "%26s %16s %8s %11sn", $1, $2, $3, $4
NR > 1 printf "%-15s %s(%0.2g) %s %s %sn", $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
$ cat 1.awk
BEGIN FS = " " ;
NR == 1 printf "%26s %16s %8s %11sn", $1, $2, $3, $4
NR > 1 printf "%-15s %s(%0.2g) %s %s %sn", $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
answered Oct 10 '17 at 3:35
fpmurphy1
2,231915
2,231915
add a comment |Â
add a comment |Â
Â
draft saved
draft discarded
Â
draft saved
draft discarded
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f397147%2fformat-the-number-of-decimal-points%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
awk -F" " '$6>0 print substr($6,1,5)' filename
â KHAN irfan
Oct 10 '17 at 0:59
As you're using AWK in your comment, note that
printf "%.3f", $6
actually cuts the field down to three decimal places, regardless of how many digits are before the point, unlikesubstr
â Fox
Oct 10 '17 at 1:17
I think you mean the 6th column - not the 5th column
â fpmurphy1
Oct 10 '17 at 3:04