I have a python script that is meant to read and write a csv locally. It also counts an average value of the number of lines. Now I need to translate it in JS native. But I don not even succeed to display it in an array. The array stays empty and I don't have any clue why.
The CSV I use look like:
outbound;API1;Restitution;1.0
outbound;API1;Restitution;1.0
outbound;API1;Operations;1.0
outbound;API2;Operations;2.0
outbound;API2;Operations;2.0
outbound;API3;Service;1.0
And when I translate it with my python script I obtain something like :
API1,0.50
API2,0.33333
API3,0.16666
The python script I want to translate:
import csv
from glob import glob
myDict = {}
filename = glob('*.csv')[0]     #take any .csv file
row_number = 0
with open(filename, 'rU') as f:     #arg 'r' for reading and 'U' for Universal, can read .csv without quotes.
    reader = csv.reader(f, delimiter=';')
    for row in reader:
        row_number +=1
        if row[1] in myDict:
            myDict[row[1]] += 1
        else:
            myDict[row[1]] = 1
data = open("output.csv", "w")
w = csv.writer(data)
for word in myDict:
    data = word, float(myDict[word])/row_number*100
    w.writerow(data)
my JS function :
var a_api = new Array();
            $.get('/data/dataTest2.csv', function(data) {
              let rows = data.split("\n");
              rows.forEach( function getvalues(thisRow) {
                let columns = thisRow.split(";");
                for (var i=0;i<a_api.length;i++){
                  if(columns[1]==a_api[i]){
                    a_api[i][1] +=1;
                  }
                  else {
                    a_api[i][0]=columns[1];
                    a_api[i][1]=1;
                  }
                }
              })
               });
console.log(a_api);
