I am struggling to find a way to write data to a CSV in Node.js.
There are several CSV plugins available however they only 'write' to stdout.
Ideally I want to write on a row-by-row basis using a loop.
Make sure your React. js server is running with npm run . Go to http://localhost:3000 and click on Import Data to open the importer modal. Upload your CSV file, match the columns and then click import.
You can use fs (https://nodejs.org/api/fs.html#fs_fs_writefile_file_data_options_callback):
var dataToWrite; var fs = require('fs'); fs.writeFile('form-tracking/formList.csv', dataToWrite, 'utf8', function (err) { if (err) { console.log('Some error occured - file either not saved or corrupted file saved.'); } else{ console.log('It\'s saved!'); } });
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With