Write CSV file column title in javascript
Clash Royale CLAN TAG #URR8PPP Write CSV file column title in javascript This is my code. I am trying to output my data as CSV and I am being successful but I can't add the title of the columns. Although I saved the CSV file but the column titles are missing. Can anyone help in this? var d= new Date(); var t=d.getHours()+":"+d.getMinutes()+":"+d.getSeconds(); var data = dataAWS var result = data.map(function(val) return t+'","'+val.payload.test_data; ).join('"n"'); var csvData = '"'+ result +'"'; var fs = require('fs'); fs.writeFile("tempN.csv", csvData, 'utf8', function (err) if (err) console.log("An error occured while saving CSV."); return console.log(err); console.log("CSV file has been saved."); ); 1 Answer 1 Without knowing more I would suggest something like: data.unshift(column_headers); var result = data.map(function(val) return t+...