0
I have 3 arrays in my code, INFO, INFOS AND TEST.
And I need to make a function
check if the position of my test variable is equal to my info variable and if it is equal, the final variable is:
In the case of the test variable in the actual code, I have 167,082 positions.
In the case of the first position of the Final array:
would be: 201 - Senior military police officers
of the second: 101 - General officers of the armed forces.
and so on.
var info = ["101", "102", "103", "201"]
var infos = ["Oficiais generais das forças armadas", "Oficiais das forças armadas", "Praças das forças armadas", "Oficiais superiores da polícia militar"]
var teste = ["201", "101", "101", "201", "103", "201", "201"]
for(i = 0;i < teste.length;i++){
for(j = 0;j < info.length;j++){
if(teste[i]==info[j]){
var final=[]
final = info[j] + " - " + infos[j]+"\n";
console.log(final);
fs.appendFile('resultado.json',final, function (err) {
if (err) throw err;
});
}
}
}
The final file always gives the following error:
EMFILE: Too Many open files, open
And It Closes Saving Only 8189 Objects.
What’s the matter, I ran the and printed
201 - Oficiais superiores da polícia militar

101 - Oficiais generais das forças armadas

101 - Oficiais generais das forças armadas

201 - Oficiais superiores da polícia militar

103 - Praças das forças armadas

201 - Oficiais superiores da polícia militar

201 - Oficiais superiores da polícia militar
– Augusto Vasques
The problem is that if I run on the console using Node it always hangs on less than 9 thousand mounted objects, in the array info and Infos I have 607 positions. And in the Test array, I have 167,000 objects and I can’t save the actual result that would be 167,000 objects in the final array.
– Gustavobezerra
I get it. Edit your question and tag
Node.js
for people who specifically understand Node to be interested in the question. Also put the error message in the question along with this explanation of the problem you just gave me, sometimes people stay only on the question and do not get to read the comments. I can’t help you because I understand JS in the browser but I don’t know anything about Node. But one thing caught my attention you do a file writing inside thefor
it would not be the case to do this writing only after the two tiesfor
end?– Augusto Vasques
I will change to check both your tip and the Node question.
– Gustavobezerra