Made a function for data collection with the ability to export data to csv.