Generate print statements

I need to pickup values provided in braces from a file with many records

I am able to get the count of number of dept's in each line .How do we write a logic to generate a print statement like below instead of using a while loop

if the count is 0 it should generate awk -F'[()]' '{print $2 }'  
count is 1 it should generate awk -F'[()]' '{print $2 "," print $4}'  
count is 2 it should generate awk -F'[()]' '{print $2 "," print $4 "," print $6} '
count is 3 it should generate awk -F'[()]' '{print $2 "," print $4 "," print $6 "," print $8} '

similarly if the count is 8 it should generate the print statements with (2,4,6,8,10,12,14,16,18)

What operating system are you using?

What shell are you using?

Why are you opposed to using a while loop?

Is this a homework assignment?

Where is the count of departments coming from?

What would a line in file.txt look like when the count of departments is 0?

Why do you want a trailing comma printed after the list of departments extracted from your input?

Once you have added a line with zero departments in it to your sample file.txt file contents, please show us the output you are trying to produce from that sample input file.

What have you tried to solve this problem on your own?

There are no braces in your sample input file (although there are pairs of matching parentheses). Please more clearly explain what you are trying to do.