can anybody response, To handle csv data papa parsing library using to convert read excel data, but while parsing browser is giving unresponsive after X minutes.
Here is the breaking lines of javascript code.
attached excel fine as well.
function csvToJSON (data) {
data = trimEmptyLastCSVLine(data);
var parseResult = Papa.parse(data, {
header: true,
dynamicTyping: true
});
var jsonArray = trimJSONArray(parseResult.data); // script throw unreposnsive
return { data: jsonArray, header: parseResult.meta.fields};
}
/**
* Trims any strings in the json output
*/
function trimJSONArray(jsonArray) {
return JSON.parse(JSON.stringify(jsonArray).replace(/"\s+|\s+"/g,'"')); // eslint-disable-line
}
function trimEmptyLastCSVLine(data) {
if(angular.isString(data)) {
return data.replace(/\r?\n(\s*,*)+\r?\n?$/g, ''); // ** mozilla thrown script error popup **
}
}