I'm generating a CSV file from an array of data using JS.
My data before the download is this:
var csv =
"Date,valA,valB,valC,valD,AVG
2016-07-01 12:00,393917,211,38534,640,9.78%,
2016-07-01 01:00,342278,171,38131,547,11.14%,
2016-07-01 02:00,265238,168,29395,547,11.08%,";
Every line has a line break character in the end ("\n").
I then add the mime type at the beginning of the string:
csv = 'data:text/csv;charset=utf-8,' + csv;,
and then encode & download:
data = encodeURI(csv);
link = document.createElement('a');
link.setAttribute('href', data);
link.setAttribute('download', filename);
link.click();
Everything works fine, but In the final file there is an empty column for some reason.
I've looked into this question but it is far too detailed. I think the solution here could be very simple.
What am I doing wrong here?