javascript - How to read and write data from csv using fast csv -
i reading data csv , transforming data. want write data new csv file getting created data not getting populated.
here have tried
const fs = require('fs'); var csv = require("fast-csv"); var stream = fs.createreadstream("/home/rahul/downloads/it.csv"); var ws = fs.createwritestream("/home/rahul/downloads/my.csv"); csv .fromstream(stream) .transform(function(data){ return data.map(function(ip) { return number( ip.split(".") .map(d => ("000"+d).substr(-3) ) .join("") ); }) }) .on("data", function(data){ console.log(data); // logs [ 5009000000, 5009255255 ] }) .on("end", function(data){ csv.write(data).pipe(ws); });
Comments
Post a Comment