I want to append a string to a new line instead of the end of the current line.
Right now, I have a following code.
fs.appendFile(`data/battle-log.csv`, `${new Date().toLocaleString()},1,0,0\r\n`, 'utf8', function (err) {
if (err) {
console.log(err);
}
});
I open the output in notepad app, and I am getting this...
2021/11/7 16:03:15,1,0,02021/11/7 16:16:18,1,0,02021/11/7 16:28:44,1,0,0
I want this instead
2021/11/7 16:03:15,1,0,0
2021/11/7 16:16:18,1,0,0
2021/11/7 16:28:44,1,0,0
Oddly enough however, when I open the csv file in notepad, and remove the seconds from Date string like this...
2021/11/7 16:03:15,1,0,02021/11/7 16:16:18,1,0,0
2021/11/7 16:28,1,0,0 // <- remove 'seconds' from Date string
The next time I run the program, it adds the string to a new line.
2021/11/7 16:03:15,1,0,02021/11/7 16:16:18,1,0,0
2021/11/7 16:28,1,0,0
2021/11/7 16:41:23,1,0,0 // <- added to a new line somehow