generate CSV file using AWK script

Hi guys

I have a text report that consists of text in some parts and data in some parts.
e.g
Report for changes in cashflows

No changes were found

Report for changes in Bills

deal_num deal_date trader maturity log_creator
DF_234 20-5-2008 tman 20-5-2009 tman
DF_235 23-5-2008 tmix 20-5-2010 tmix
DF_236 24-5-2008 tmee 20-5-2009 tmee
DF_237 27-5-2008 xlog 22-5-2009 tlog

4 row(s) found
... the report goes on and on like that

The issue is that i want to convert the whole report into CSV format,including the text.The data shown above should also be converted to csv with the heading and data correctly matched. and aligned

The script that generates the report is an AWK script and i want to use an AWK script as well to generate the CSV file from this report and store it in some location.

Any help or ideas on how to go about it.I am very new to unix AWK scripting.

Thanks in advance.

awk '{print $1","$2","$3","$4","$5}' < /tmp/file.txt > /tmp/file.csv

If the report has fixed column number of 5, than this can work, just replace the paths.

That's a tad difficult if there are more than five fields.

Not sure what your awk command is but awk '{OFS=","};{print $0 (or print $1,$3,$5 etc)}' myfile > myfile.csv will output the result separated by commas.