Format problem while converting text file to csv

Hi ,

I need a help in following scenario.I tried searching in google but couldn't able to find the exact answer. Sorry if i am re-posting already answered query.
While i am trying to convert into log file into csv i couldn't able to get the format which i am looking for.

I converted file with the following command

awk -F":" '{ print $1","$2","$3}' < test.txt > test.csv
Employee Total: 345
 Employee Leave:   2
 Employee Present in Office:  333
 Employee Working Out of Office: 10

Since awk is not ignoring spaces and considering white space & colon as delimiter data is divided into different columns i.e. more than 3 columns.
Is there a way to get above details into two columns in csv file.

Thanks in advance.

awk '{$1=$1}1' FS=":" OFS="," test.txt

Try:

awk '{sub(/^  */, x); $1=$1}1' FS=': *' OFS=, file

You could also try:

awk -F': *' '{sub(/^ */,"");$1=$1}1' OFS=, test.txt

Edit: wow nearly the same as above - great minds think alike

bipinajit,Scrutinizer,Chubler_XL - Thanks to you guys

Each and every solution worked very well. Have a good day :slight_smile: