Changed function downloadCsv to have switch statement instead of
numerous if statements