I am trying to manipulate a file which contains numbers in scientific notation, but without the e
symbol, i.e. 1.2e+3
is written as 1.2+3
.
The easiest thing I thought of doing with awk
was to replace +
with e+
, using the gsub
function and do my calculation in the new file. The same goes for the minus case. So a simple fix could be done using the following command
awk '{gsub("+", "e+", $1); print $1, $2, $3, $4, $5}' file_in
and do the same in all the columns.
However the file contains also negative numbers which makes things a bit more complicated. A sample file can be seen bellow
1.056000+0 5.000000-1 2.454400-3 2.914800-2 8.141500-6
2.043430+1 5.000000-1 2.750500-3 2.698100-2-2.034300-4
3.829842+1 5.000000-1 1.969923-2 2.211364-2 9.499900-6
4.168521+1 5.000000-1 1.601262-2 3.030919-2-3.372000-6
6.661784+1 5.000000-1 5.250575-2 3.443669-2 2.585500-5
7.278104+1 5.000000-1 2.137055-2 2.601701-2 8.999800-5
9.077287+1 5.000000-1 1.320498-2 2.961020-2-1.011600-5
9.248130+1 5.000000-1 3.069610-3 2.786329-2-6.317000-5
1.049935+2 5.000000-1 4.218794-2 3.321955-2-5.097000-6
1.216283+2 5.000000-1 1.432105-2 3.077165-2 4.300300-5
Any idea on how to manipulate and calculations with such a file?