My understanding is that they both create writeable streams, but I'm unsure of what the point of parsing the data is if you just go and format it afterwards like in the example below.
fs.createReadStream(path.resolve(__dirname, 'assets', 'snake_case_users.csv'))
.pipe(csv.parse({ headers: true }))
.pipe(csv.format({ headers: true }))
.transform((row, next) => {
User.findById(row.id, (err, user) => {
if (err) {
return next(err);
}
return next(null, {
id: row.id,
firstName: row.first_name,
lastName: row.last_name,
address: row.address,
// properties from user
isVerified: user.isVerified,
hasLoggedIn: user.hasLoggedIn,
age: user.age,
});
});
})
.pipe(process.stdout)
.on('end', () => process.exit());