I have a file in which the data is in the form like
abc@email.com:name
ewdfgwed@gmail.com:nameother
wertgtr@gmsi.com:onemorename
I want to store the emails and names in arrays like
email = ["abc@email.com","ewdfgwed@gmail.com","wertgtr@gmsi.com"]
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);
}