I'm hoping for some guidance here, a little out of my depth here, but looking to have a filedropzone, where a user drops or selects a file, the button would trigger a (popup?) for confirmation which column contains the emailadress and if the first row contains a header.
I am assuming that I can use the next query to update with those inputs into this script:
function csvToJson(csvString) {
const lines = csvString.split('\n');
const headers = lines[0].split(',');
return lines.slice(1).map(line => {
const values = line.split(',');
return headers.reduce((row, header, index) => ({
...row,
[header.trim()]: values[index].trim() // trim to remove any leading/trailing spaces
}), {});
});
}