I'm working on a node project which enables users to upload .csv files that will then be possibly added to a mongo database. I have it working using a different module, but with large files, it will finish reading and redirect the user before all the data has been processed. I think promised-csv will help with this, but I'm having trouble figuring out how to set this up. This is the current setup:
app.post('/import', isLoggedIn, function(req, res) {
var reader = csv.createCsvFileReader(req.files.spreadsheet.path, {columnsFromHeader:true, 'separator': ','});
reader.addListener('data', function(data) {
//do stuff with data here.
})
reader.addListener('end', function(){
fs.unlink(req.files.spreadsheet.path, function(err) {
res.redirect('/');
})
})
});