I have a file in which the data is in the form like
[email protected]:name
[email protected]:nameother
[email protected]:onemorename
I want to store the emails and names in arrays like
email = ["[email protected]","[email protected]","[email protected]"]
names = ["name","nameother","onemorename"]
Also, guys, the file is a little bit large around 50 MB so also I want to do it without using a lot of resources
I have tried this to work but can't make things done
// read contents of the file
const data = fs.readFileSync('file.txt', 'UTF-8');
// split the contents by new line
const lines = data.split(/\r?\n/);
// print all lines
lines.forEach((line) => {
names[num] = line;
num++
});
} catch (err) {
console.error(err);
}