Hello all,
I have a .csv file of 16 columns consists of bunch of numbers.
6.45E+01 1.17E+01 8.10E+04 8.21E+01 8.50E+00 1.20E+01 1.02E+01 1.88E+01 1.86E+04 3.53E+03 1.09E+07 3.82E+04 2.09E+03 3.57E+03 2.98E+03 3.93E+03
6.34E+01 3.23E+01 9.24E+04 3.25E+01 3.18E+01 3.35E+01 3.26E+01 4.19E+01 2.96E+04 1.59E+04 2.86E+07 1.61E+04 1.58E+04 1.59E+04 1.59E+04 1.76E+04
3.82E+01 3.29E+01 1.04E+05 3.25E+01 3.22E+01 3.23E+01 3.23E+01 3.73E+01 1.75E+04 1.63E+04 5.78E+07 1.62E+04 1.62E+04 1.62E+04 1.62E+04 1.71E+04
4.16E+01 3.21E+01 4.16E+04 3.26E+01 3.25E+01 3.25E+01 3.27E+01 4.24E+01 1.78E+04 1.62E+04 3.85E+07 1.62E+04 1.62E+04 1.62E+04 1.62E+04 1.79E+04
4.29E+01 3.28E+01 1.76E+04 3.30E+01 3.31E+01 3.29E+01 3.31E+01 4.08E+01 1.84E+04 1.62E+04 2.48E+07 1.62E+04 1.62E+04 1.62E+04 1.62E+04 1.79E+04
6.02E+03 2.88E+02 1.78E+04 4.71E+02 3.23E+01 9.60E+03 3.22E+01 3.74E+01 4.26E+06 1.34E+06 2.21E+07 5.42E+05 1.62E+04 1.65E+07 1.62E+04 1.71E+04
4.09E+01 3.21E+01 4.85E+04 7.88E+04 3.25E+01 1.45E+03 3.30E+01 4.20E+01 1.80E+04 1.64E+04 2.93E+07 3.56E+07 1.62E+04 2.66E+06 1.62E+04 1.79E+04
I want to take the last 8 columns in awk and multiply them with 100 and append the results in new column (column 17 to 24).
This is the code I have tried so far:
awk 'BEGIN{FS=",";RS="\n";OFS=",";ORS="\n";} {for (i=1;i<=8;++i){$(NF+i)=$(i+8)*100;}}1' file.csv > newfile.csv
I am getting the results, but problem is, it is appending extra "," in the csv before every new columns. So after 1 extra "," after the 16th column with new data from column 9, then 1 extra "," columns after 17th with the new data from column 10 and so on..... Basically it is adding extra "," after every loop for the value of i.
Output Observing:
>awk 'NR==1 {print $0}' newfile.csv
2.668750000000000000e+01,1.687500000000000000e+00,1.500000000000000000e+00,6.712500000000000000e+01,1.625000000000000000e+00,4.187500000000000000e+00,7.875000000000000000e+00,1.375000000000000000e+00,4.298700000000000000e+04,9.099000000000000000e+03,3.378000000000000000e+03,1.111399900000000000e+07,6.906000000000000000e+03,1.057600000000000000e+04,5.911000000000000000e+03,2.280000000000000000e+03,0.030705,,0.00649929,,,0.00241286,,,,7.93857,,,,,0.00493286,,,,,,0.00755429,,,,,,,0.00422214,,,,,,,,0.00162857
Confused on how to fix this...
Also, how to add heading to the new columns that I just created?
Thanks in advance