I need assistance with converting the information in my text file into an array of objects. Below is a snippet of the data from the text file:
DOCNO NETAMOUNT IREF1 IREF2 DOCDT
001 30000 50 100 6/7/2020
2 40000 40 90 6/7/2020
Currently, this is my code implementation:
reader.onload = (ev)=>{
const data = reader.result;
var txtData = data.toString();
console.log(data,"txt data");
var lines = txtData.split(' ');
for(var line = 0; line < lines.length; line++){
console.log(lines[line]);
}
};
reader.readAsText(file);
}
The desired output format I am aiming for is as follows:
0: {DOCNO: "001", NETAMOUNT: "30000", IREF1: "50", IREF2: "100", DOCDT: "6/7/20"}
1: {DOCNO: "2", NETAMOUNT: "40000", IREF1: "40", IREF2: "90", DOCDT: "6/7/20"}