My original question did not make sense based on feedback. Trying to see if there is an alternate way to read a CSV with Papa parse.
My current code:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<script src="./papaparse.min.js"></script>
<script>
var data;
// Target first (and only) file selected
function handleFileSelect(evt) {
var file = evt.target.files[0];
// Parse the file
Papa.parse(file, {
header: true,
download: true,
dynamicTyping: true,
complete: function(results) {
data = results;
console.log(data);
}
});
}
// Run handleFileSelect function when document is ready
$(document).ready(function(){
$("#testCsv").change(handleFileSelect);
});
</script>
<!--File button to upload file-->
<input type="file" id="testCsv" name="files"/>
EDIT: Apparently I need to do some more research based on the down votes. Sorry, brand new to this stuff. My next attempt:
var data;
function parseCSV(file) {
Papa.parse(file, {
header: true,
download: true,
dynamicTyping: true,
complete: function(results) {
data = results;
console.log(results); // results appear in dev console
}
});
}
parseCSV(document.getElementById("testCSV").files[0]);
Which returns an error:
ReferenceError: document is not defined
Doing more research.