Closed PrasannaBrabourame closed 4 years ago
Hi @PrasannaBrabourame , that's actually the expected behaviour. As long as you use the same instance of csv writer, you can keep writing to the same file.
If you want to create a new file each time you run the cron job, create a new instance in the CronJob
's callback (i.e. the 2nd argument).
Let me know if this doesn't solve your problem 😉
const job = new CronJob('/30 ', async function () { var data = [{"place": "Puducherry","state":"PY"},{"place":"Chennai","state":"TN"}] await csv.csvWriter.writeRecords(data) }
By executing this first time csv looklike place,state puducherry,PY chennai,TN
By executing this second time csv looklike place,state puducherry,PY chennai,TN puducherry,PY chennai,TN
By executing this third time csv looklike place,state puducherry,PY chennai,TN puducherry,PY chennai,TN puducherry,PY chennai,TN
Similarly the value keep on increasing