0

I'm making something that tracks something in a csv file. The csv file has a specific format that I need to adhere to. Each time changes are made, the file gets completely rewritten because I edit the middle of the file as well. To do this, I'm using the fs library and using fs.writeFileSync because I want the execution to halt while it runs.

I've noticed that there are times where I look at the csv file that gets outputted when I write a file with around 10 or more columns, but sometimes newlines are added for some reason I cannot tell.

for example, This code stub adds one of the rows to what will be written, and tracking.playerData is an array of objects that contains a key 'id' which is entirely comprised of numbers.

for (let player of tracking.playerData) {
    console.log("player.id:\t" + player.id);
    text += "," + player.id;
}

for some reason, in the csv file, there are newLines created after 12 or so people have been put in and I can't find out why.

Treyara
  • 47
  • 1
  • 7

0 Answers0