const fs = require('fs');
const readline = require('readline');
const path1 = __dirname + '/aid_imei_mac.log';
const path2 = __dirname + '/aid_imei_mac1.log';
let wf = fs.createWriteStream(path2)
const strem = process.stderr;
const rl = readline.createInterface({
input: fs.createReadStream(path1),
});
let i = 0
rl.on('line', (line) => {
if (line.split(',').filter(i => !!i).length == 3) {
wf.write(line + '\n')
i++
strem.cursorTo(0)
strem.write(`写入${i}行${(wf.bytesWritten / 1024 / 1024).toFixed(2)}M 数据`)
}
});
rl.on('close', function () {
wf.end(function () {
console.log('\n文件全部写入完毕');
console.log(`共写入${(wf.bytesWritten / 1024 / 1024).toFixed(2)}M 数据`);
});
});