Plain text table to csv problems

I´m trying to input a plain text table and I want to output a csv file with semicolon field separator.
I have some problems with the \r and the fields with more of one line.. Some gnu util to do this without problems or awk solution?

I´m attaching the original plain table file and the needed csv format in the output.

Thank you for any help!

Any attempts / ideas / thoughts from your side?

Try using

tr

for straight-forward substitutions like this is much simpler:

$ cat ifile.txt | tr -s '[:blank:]' ',' > ofile.txt

or

sed method

sed 's/ \+/,/g' ifile.txt > ofile.csv
cat ofile.csv

1,4,22.0,3.3,2.3
2,2,34.1,5.4,2.3
3,2,33.0,34.0,2.3
4,12,3.0,43.0,4.4