I'm creating a csv file using javascript but I don't understand how can I insert a name for the document and also how can I insert a first row with "Name", "Langitude", "Longitude"
function createCSV() {
console.log("arrayInfo.length", arrayInfo.length)
if (arrayInfo.length > 0) {
const rows = []
for (var i = 0; i < arrayInfo.length; i++) {
rows.push(arrayInfo[i])
}
console.log("rows ", rows)
let csvContent = "";
rows.forEach(function (rowArray) {
let row = rowArray.join(",");
console.log("row ", row)
console.log("rowArray ", rowArray)
csvContent += row + "\r\n";
});
console.log("csvContent ", csvContent, [csvContent])
var csvData = new Blob([csvContent], { type: 'text/csv;charset=utf-8;' });
var csvURL = window.URL.createObjectURL(csvData);
console.log("csvData ", csvData)
window.open(csvURL);
}
else {
console.log("no csv")
}
}
this is the function that I use, In your opinion how can I do?