I've found some code in here on how to export data from an array to a CSV file. I just have a few problems that needs to be address since I'm not very familiar with the code that I got.
listofconstraints.forEach(function(infoArray, index){
dataString = infoArray.join(",");
csvContent += dataString + "\n";
});
var encodedUri = encodeURI(csvContent);
var link = document.createElement("a");
link.setAttribute("href", encodedUri);
link.setAttribute("download", "listofconstraints.csv");
link.click();
It works properly but it lacks some of the features that I need including, checking if the file already exists, setting the path of the file, and if it does exists, overwriting it.
,'or"in them - this simplistic csv creator will fail creating a valid csv file if they do - it will still create the file and download will happen ... just that things like excel will not read the file as intended