File reading and writing in csv

currently I am working on a requirement where I will be reading text file like
AB
ABX
ABY
ABZ
CD
CDX
CDY
CDZ
so for above input 'AB' & 'CD' is unique.

all these inputs I am collecting in an array and further passing to a function and for every input am getting an output which need to write in a csv like

AB,o/pAB,o/pABX,o/pABY,o/pABZ
CD,o/pCD,o/pCDX,o/pCDY,o/pCDZ

This I am able to achieve with the help of running loops & write it in csv but I want to achieve with help of more sophisticated data structure like map,
Topic archived. No new replies allowed.