I'm pretty sure this is simple, but haven't been able to figure it out.
Have tried using async/await without success.
I have the below function, and I need the const file = removeFirstNRowsFromCsv(listOfFiles[i], 6); line to wait for const file = removeFirstNRowsFromCsv(listOfFiles[i], 6); to resolve to a value (right now is returning undefined and the removeFirstNRowsFromCsv() doesn't resolve until function already errors out).
Any help would be appreciated!
const handleUpload = (listOfFiles) => {
    for (let i = 0; i < listOfFiles.length; i++) { 
        const file = removeFirstNRowsFromCsv(listOfFiles[i], 6);
        dfd.readCSV(file,{skipEmptyLines: true}).then(df => handleQa(df,file, i));
    }
}
// EDITED TO INCLUDE BELOW 
const removeFirstNRowsFromCsv = (csvFileRef, n) => {
    const reader = new FileReader();
    reader.readAsText(csvFileRef);
    reader.onload = function() {
        const csvData = reader.result;
        const csvRows = csvData.split(/\r?\n|\r/);
        const csvRowsNew = csvRows.slice(n);
        const csvRowsNewString = csvRowsNew.join('');
        const blob = new Blob([csvRowsNewString], { type: 'text/csv' });
        const newFile = new File([blob], csvFileRef.name, { type: 'text/csv' });
        return newFile;
    }
}
 
    