function sanitise_csv_cell(cell_data) {
    // ensure numbers are converted to string
    cell_data = cell_data.toString()
    // Replace all double quotes with 2 double quotes
    cell_data = cell_data.replace(/"/g, '\"\"')
    var whitespaceCheckRegex = /\s/
    // if cell_data has a comma, or new line, or its first or last character is a
    // whitespace, then wrap the entire expression in double quotes
    if (
        cell_data.indexOf(',') >= 0
        || cell_data.indexOf('\n') >= 0
        || whitespaceCheckRegex.test(cell_data.charAt(0))
        || whitespaceCheckRegex.test(cell_data.charAt(cell_data.length - 1))
    ) {
        cell_data = '\"' + cell_data + '\"'
    }
    return cell_data
}
string cell data sanitiser, returns a CSV formatted string
@param {string} cell_data