I've created a function that retrieves and displays values from a CSV file.
Here is the code for the function:
var IDArr = [];
var fileInput = document.getElementById("csv");
readFile = function() {
console.log("file uploaded")
var reader = new FileReader();
reader.onload = function() {
IDArr.push(reader.result);
var promises = IDArr.map(function(key) {
return firebase.database().ref("/Agents/").child(key).once("value");
});
Promise.all(promises).then(function(snapshots) {
snapshots.forEach(function(snapshot) {
console.log(snapshot.key + ": " + snapshot.val());
});
});
};
reader.readAsBinaryString(fileInput.files[0]);
};
if (fileInput) {
fileInput.addEventListener('change', readFile);
}
The function above generates the image displayed below:
https://i.sstatic.net/5M7HM.png
Now, I need to enclose each ID value in quotation marks and separate them with commas. For example, I want to create a new array like this: "75799757","9744710", "79989647", "99029704". How can I achieve this?