我试图使用节点js逐行读取文件,但是我不确定如何使用节点js检查文件中的行是否为空
data.js
console.log("123")
console.log("123")
console.log("123")
console.log("123")
file.js
var lineReader = require('readline').createInterface({
input: require('fs').createReadStream('./data.js')
});
lineReader.on('line', function (line) {
console.log('Line from file:', line);
});
我得到了此输出
Line from file: console.log("123")
Line from file:
Line from file: console.log("123")
Line from file:
Line from file:
Line from file: console.log("123")
Line from file:
Line from file:
Line from file:
Line from file: console.log("123")
但是我想要如何检查行是否为空。
答案 0 :(得分:2)
尝试检查每行的字符串长度:
var count_in = (from x in conn.Table<SoccerAvailability>().Where(x => x.SoccerStatus == IN) select x).Count();
上述逻辑只会记录非空输入,但您可以将其更改为所需的任何内容。