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