If my table is like the following:-

Name Age
John 10
Luke 20
Roger 30


What I would like to do is to output above to a csv file in the following format:-

John, Luke, Roger
10, 20, 30

I have the table in an array which i assume needs to be manipulated..
Any ideas how i can do this ?