Reputation: 35
I have csv files and I need to scale the first column of csv file with value 1.3. I am able to scale the first column of csv file with value 1.3 using awk. Here is the one line code which I have used for scaling:
$ awk -F, '{$1=$1*1.3;print}' OFS=, input.csv > output.csv
Now the problem is that after scaling, I want the result upto 9 or 10 decimal places but I am getting upto 5 decimal places.
input.csv file format:
9.876160000E-07 , 6.5940E-03
9.876180000E-07 , 4.0718E-03
output.csv file format (after running awk command):
1.2839e-06, 6.5940E-03
1.2839e-06, 4.0718E-03
Expected Output.csv file format:
1.28390080e-06, 6.5940E-03
1.28390340e-06, 4.0718E-03
What to change in awk command to get the expected result?
Upvotes: 0
Views: 260
Reputation: 37404
Like this, using sprintf
:
$ awk '{$1=sprintf("%.8e",$1*1.3);print}' file
1.28390080e-06 , 6.5940E-03
1.28390340e-06 , 4.0718E-03
Upvotes: 1