Is there anyway to turn a variable containing csv data into a file that is downloaded onto the users computer?

I made a button that turns the collection data into a csv format. I would like to be able to then create this data into a file that is downloaded(by button push) onto the users computer