0
我有一個> 200線CSV文件,節點的readline的模塊在文檔的末尾拋出此錯誤的方法:的Readline拋出的最後一行錯誤:「對」
has no method 'on'
at new Interface (readline.js:107:11)
at Object.exports.createInterface (readline.js:41:10)
該文件確實有最後一個空行,可能會導致問題?
request('http://csvdata.com/csvfile', function (error, response, csvData) {
// If Request Successful
if (!error && response.statusCode == 200) {
// Defaults
var instream = csvData;
var outstream = new stream;
var rl = readline.createInterface(instream, outstream);
// Go through each line
rl.on('line', function(line) {
console.log(line);
});
'readline.createInterface()'預計,該選項的對象,而不是每個選項的參數。嘗試'readline.createInterface({input:instream,output:outstream});'編輯:只讀舊文檔,它用來接受多個參數,更新的文檔只允許一個,這是一個選項對象。 –
我仍然收到同樣的錯誤。我認爲這可能是因爲.on('行)在文檔中達到中斷'/ n'時觸發,也許我的文檔缺少一個。 – ac360