addition of function sampleToCSV.