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

[Question] end() usage on writing data to csv file

Open 300LiterPropofol opened this issue 4 years ago • 0 comments

Hello!

Thank you for creating this awesome package. I have a question on the usage of end() though.

I am confused about how the syntax end() functions in the csv file writing. I have some similar code as below:

const fs = require('fs'); // build-in module
const fastcsv = require('fast-csv');

const fileName = `File_${String(Math.round(new Date().getTime()))}.csv`;
const csvFile = fs.createWriteStream(fileName);
fastcsv.write(dataArray, { headers: true }).pipe(csvFile);

I didn't use any end() syntax since I don't know where to put it. And the syntax above can output a file for me. I wonder without this end() syntax, is it possible that not all data in dataArray is written down inside the csv? For example, if I am sending this fileName to another function and uploads this file using the name. Is it possible that what I upload is not the full dataArray?

Could you explain more about the usage of end() ? thank you very much!

300LiterPropofol avatar Feb 25 '22 15:02 300LiterPropofol