Replace comma delimiter by newline

The input file is as below

 
AR,age,marks,roll,section,evin,25,80,456,A,atch,23,56,789,B,eena,24
,78H245,C,Ps,ot,ecessary,hat,ame comes first then age and rest AR
AZ,kevin,25,80,456,A,Satch,23,56,789,Satch,23,56,789,B,Meena,24,78,H245,C,AZ
................
................

I am writting the below code .
I have to serch the lines containing strings in between the top name.
The top names are AR,AZ...

echo "Give the top name"
read top
/usr/bin/sed -n '/$top/,/$top/p' inputfile | /usr/bin/sed '/,/\\n/g' > exclude_file

example If the top name is AR,output will be

age
marks
roll
section
evin
25
80
456
A
atch
23
56
789
B
eena
24
78H245
C
Ps
ot
ecessary
hat
ame comes first then age and rest
awk '/AR/ {f=(!f);next} f' RS=",|\n"

This has a problem since AR is not separate from the text. It then does not print last line.
ame comes first then age and rest

i have modified the input file content as below

 
AR,age,marks,roll,section,evin,25,80,456,A,atch,23,56,789,B,eena,24
,78H245,C,Ps,ot,ecessary,hat,ame,AR
AZ,kevin,25,80,456,A,Satch,23,56,789,Satch,23,56,789,B,Meena,24,78,H245,C,AZ
................
................

And i have also tried your code...but it is not working.

Is this not what you want (from AR to AR)?

age
marks
roll
section
evin
25
80
456
A
atch
23
56
789
B
eena
24

78H245
C
Ps
ot
ecessary
hat
ame

Yes,,,thats what i want but the code is not working...after i ran the code it is expecting some input

echo "AR,age,marks,roll,section,evin,25,80,456,A,atch,23,56,789,B,eena,24
,78H245,C,Ps,ot,ecessary,hat,ame,AR
AZ,kevin,25,80,456,A,Satch,23,56,789,Satch,23,56,789,B,Meena,24,78,H245,C,AZ" | awk '/AR/ {f=(!f);next} f' RS=",|\n"

or

awk '/AR/ {f=(!f);next} f' RS=",|\n" infile

Hi Jotne,

Thank you for your help..it is working fine.
But AR is not hard coded, I have to keep this value in variable.
If i do it as below, it is not working..Can you pls suggest.

 
top="AR"
awk '/$top/ {f=(!f);next} f' RS=",|\n" infile
 
top="AR"
awk '$0~s {f=(!f);next} f' RS=",|\n" s="$top" infile

Thank you Jotne...It worked ...