let objCsv = { size: 0, dataFile: [] }; function readCsv(input: any): any { if (input.files && input.files[0]) { let reader = new FileReader(); reader.readAsBinaryString(input.files[0]); reader.onload = event => { objCsv.size = event.total; // @ts-ignore objCsv.dataFile = event.target.result; return parseData(objCsv.dataFile); }; } } function parseData(data: any): any { let csvData = []; const lineBreak = data.split('\n'); lineBreak.forEach(res => { csvData.push(res.split(',')); }); console.table(csvData); return csvData; } export { readCsv };