1function uploadDealcsv () {};
2
3 /*------ Method for read uploded csv file ------*/
4 uploadDealcsv.prototype.getCsv = function(e) {
5
6 let input = document.getElementById('dealCsv');
7 input.addEventListener('change', function() {
8
9 if (this.files && this.files[0]) {
10
11 var myFile = this.files[0];
12 var reader = new FileReader();
13
14 reader.addEventListener('load', function (e) {
15
16 let csvdata = e.target.result;
17 parseCsv.getParsecsvdata(csvdata); // calling function for parse csv data
18 });
19
20 reader.readAsBinaryString(myFile);
21 }
22 });
23 }
24
25 /*------- Method for parse csv data and display --------------*/
26 uploadDealcsv.prototype.getParsecsvdata = function(data) {
27
28 let parsedata = [];
29
30 let newLinebrk = data.split("\n");
31 for(let i = 0; i < newLinebrk.length; i++) {
32
33 parsedata.push(newLinebrk[i].split(","))
34 }
35
36 console.table(parsedata);
37 }
38
39
40
41 var parseCsv = new uploadDealcsv();
42 parseCsv.getCsv();