I'm trying to create an interface to display a csv using Google script. However, whenever I load the file I get this error
`1729820382-mae_html_user_bin_i18n_mae_html_user.js:39 Uncaught TypeError: Failed due to illegal value in property: 0
at Td (1729820382-mae_html_user_bin_i18n_mae_html_user.js:39)
at Pd (1729820382-mae_html_user_bin_i18n_mae_html_user.js:39)
at 1729820382-mae_html_user_bin_i18n_mae_html_user.js:6
at 1729820382-mae_html_user_bin_i18n_mae_html_user.js:21
at Object.fileToCsv (1729820382-mae_html_user_bin_i18n_mae_html_user.js:38)
at loadFile (<anonymous>:10:23)
at HTMLInputElement.onchange (VM1402 userCodeAppPanel:1)`
The console log is showing the file correctly, but it seems to be tripping up when it tries to pass it to the Google script. Do I need a special file reader?
HTML is here
<!DOCTYPE html>
<html>
<head>
<base target="_top">
</head>
<body>
<input type="text" id="itemHolder" name="itemHolder" style="display:none"/>
<input type="file" id="myFile" name="myFile" onchange="loadFile(event)"/>
<p id="textStuff"></p>
</body>
</html>
<script type="text/javascript">
function loadFile(event) {
var input = event.target.files[0];
console.log(input)
google.script.run.fileToCsv(input);
}
function printout(array){
console.log("Try")
var spot = document.getElementById('textStuff');
spot.innerHTML = array;
}
</script>`
GAS Here
function fileToCsv(myFile){
var strData = myFile.getBlob().getDataAsString();
Logger.log(strData);
return strData;
//return CSVToArray( strData )
}