const fs = require('fs');
const filePath = './nf.txt';
try {
const text = fs.readFileSync(filePath, 'utf8');
let lines = text.split('\n');
console.log(lines.length);
const batchSize = 8000;
let batchCount = 0;
let currentBatch = [];
lines.forEach(line => {
currentBatch.push(line);
if (currentBatch.length === batchSize) {
const newFilePath = `../nf/nf_${batchCount}.txt`;
fs.writeFileSync(newFilePath, currentBatch.join('\n'));
batchCount++;
currentBatch = [];
}
});
if (currentBatch.length > 0) {
const newFilePath = `../nf/nf_${batchCount}.txt`;
fs.writeFileSync(newFilePath, currentBatch.join('\n'));
}
} catch (error) {
console.error(`发生错误:${error}`);
}