Only sed and nothing else
sed 's/ \+/,/g' ifile.txt > ofile.csv
cat ofile.csv
1,4,22.0,3.3,2.32,2,34.1,5.4,2.33,2,33.0,34.0,2.34,12,3.0,43.0,4.4
awk may be a bit of an overkill here. IMHO, using tr for straight-forward substitutions like this is much simpler:
awk
tr
$ cat ifile.txt | tr -s '[:blank:]' ',' > ofile.txt
here is the awk versionawk 'BEGIN{print "ID,No,A,B,C"}{print $1","$2","$3","$4","$5}' ifile.txt
awk 'BEGIN{print "ID,No,A,B,C"}{print $1","$2","$3","$4","$5}' ifile.txt
output:
ID,No,A,B,C 1,4,22.0,3.3,2.3 2,2,34.1,5.4,2.3 3,2,33.0,34.0,2.34,12,3.0,43.0,4.4