-2
I have a file .csv
with 3 columns separated by comma, I need to go through this file and each row skip to the next until the end of the file, but when going through this file in my for it is always returning the first record and in the last column is catching the \r\n
+ the first column below.
Filing cabinet:
1,123,Processado
2,456,Processado
3,789,Processado
Code:
var output = [];
var linhas = arquivo;
for (let reg of linhas) {
let dados = linhas.split(",");
let obj = {
id : dados[0],
num : dados[1],
status : dados[2],
}
output.push(obj);
output:
[
{
"id": "1",
"num": "123",
"status": "Processado\r\n2",
}
]
Does the file variable already come broken in lines? How does it get its value?
– bfavaretto