I am currently trying to add some validation of some description in regards to how I want a particular .CSV format to be before it continues parsing using PapaParse.
So my idea was to check the headers first and if they equate to the following:
Extension, company, name
Then continue parsing otherwise I can throw back an error message stating the format was wrong.
All the parsing is done using PapaParse.
Ave had no joy with it but below is the current code:
var result = [];
$("#CSV-Upload").click(function () {
$("input[type=file]").parse({
config : {
header : true,
skipEmptyLines : true,
complete : function (results, file) {
console.log("This file done:", file, results);
var string = JSON.stringify(results['data']);
result.push(string);
console.log("CSV Array: " + string);
}
},
complete : function () {
console.log("All files done!");
}
});
$("#csv-file").val('');
});