how to convert this file into comma delimited format

Hi experts,
I need urget help! I have the a text file with this format:

Types of fruits
Name of fruits
1,1
Farm_no,1
apple,1
pineapple,1
grapes,1
orange,1
banana,1
2,2--->this is the record seperator
Farm_no,2
apple,1
pineapple,1
grapes,3
orange,2
banana,1
3,3--->this is the record seperator
Farm_no,3
apple,4
pineapple,2
grapes,3
orange,2
banana,0

I need to parse this txt file into csv format.

The output need to look like this:

FARM_no,apple,pineapple,grapes,orange,banana
1,1,1,1,1,1
2,1,1,3,2,1
3,4,2,3,2,0

Anyone have any idea?Please help!

Thank a lot!

Thanks.

Closed, double post. Read the rules!

Continue here: