Csv export

Add the CSV export functionality.