fast-csv icon indicating copy to clipboard operation
fast-csv copied to clipboard

file size of the file written is zero

Open ubihot opened this issue 4 years ago • 0 comments

Describe the bug I am using fast-csv to create csv files. I am creating two files consecutively one after the other. Obviously, waiting for one to finish and then create the new file. What I'm doing next is to check the file size of the files created, and what happens is that the file size of the first file is correct but the file size of the second file is zero bytes and I haven't figured out why this is the case.

Internally, the function that creates the csv file is using the writeToPath function. I've read here, that createWriteStream which is used inside writeToPath will truncate the file it already exists, but in my case none of the files already exist.

I was wondering if the zero bytes are due to the consecutive call of my functions but I don't think so. Any idea on why I'm getting correct file size for the first file and zero bytes for the second one?

To mention is that the files content are correct but the second file size is zero (i.e. truncated)

Parsing or Formatting?

  • [ ] Formatting
  • [ ] Parsing
  • [X] Writing

To Reproduce

await preprocess(params); // create first csv file

await preprocess(params); // create second csv file

inside preprocess:

const promisedRows = rows.slice(1).map(alterRow);
const outrows = [
  headers,
  ...(await Promise.all(promisedRows)),
];
writeToPath(outFilePath, outrows, {quote: false});

Expected behavior Expecting to get the correct file size for both files.

Screenshots Screenshot 2021-06-22 at 12 06 09

Desktop (please complete the following information):

  • OS: MacOS
  • OS Version: 11.4
  • Node Version: v14.15.5

ubihot avatar Jun 22 '21 11:06 ubihot