您好我试图简单地传输我的csv文件的内容,并且我有一些非常烦人的问题。贝娄是我的代码,我的挫折隐藏在我的评论中。
var fileReadStream = fs.createReadStream(inFile);
// For some reason readable will yield only the last line of my file
// and if I listen for 'data' I still just get the last line of my file
fileReadStream.on('readable', function() {
process.stdout.write(fileReadStream.read().toString());
}).on('end', function() {
i ++;
next();
});
对此的任何帮助都会很棒。另外,我对如何正确制作管道非常困惑。根据我的解释,我觉得与管道对象一样,管道将简单地写入管道内的对象,然后调用该对象的读取。但是,我还没有能够顺利工作。也许当我解决这个问题时,我可以更容易地找出管道。感谢。
答案 0 :(得分:0)
你应该可以简单地做一些事情:
var fileReadStream = fs.createReadStream(inFile);
fileReadStream.on('end', function() {
i++;
next();
}).pipe(process.stdout);