Hi ,
you need to get data in csv file format. How to insert the data and modify the data is on your interest.
for this there is function in SOAR Utilities (which in AppExchange) called String to attachment.
I think this function help full for you.
Thanks,
Sai