convert this into csv using awk/shell script

Hi Scripting gurus,

I need to convert following text snippet into csv. please help

Input

heading1 = data1
heading2 = data2
..
..
heading n = data n

heading 1 = data1
..
..

Output

data1,data2,....,data n
data1,data2,....data n

Even a small help like how to go ahead is appreciated.

Thanks
Ajay

You can use awk for this issue.

awk -F'=' '{ print $2}' .make sure that you use escape sequence so ,data2,date3 will print on the same line..

use loop each time to check if heading 1 is repeated or not ..if repeated print newline...

perl -ne'print/=\s*(.*)/,(eof)?$/:","' infile
$num=<>;
undef $/;
open FH,"<file";
$str=<FH>;
@arr=split("\n",$str);
for($i=0;$i<=$#arr;$i++){
	if (((1+$i) % $num) == 0){print $arr[$i]."\n";}
	else {print $arr[$i].",";}
}