const path = "/home/Downloads/grafana_data_export.csv";const readline = require('readline');const fs = require('fs');var lineReader = require('line-reader');var count = 0;var totalRequests = 0;var peakRequest = 0;var peakRequestDate;lineReader.eachLine(path, function(line, last) {`let res = line.split(";");` `let requests = Number(res[2]);` `count++;` `totalRequests = totalRequests + requests;` `if(requests > peakRequest){` `peakRequest = requests;` `peakRequestDate = res[1];` `}` `if(last){` `console.log("Total Requests = ",totalRequests);` `console.log("Peak Request = "+peakRequest+" on "+peakRequestDate);` `console.log("Average request = ",totalRequests/count);` `}` });Sample row in csv = "Sdds";"2019-09-17T19:44:00+05:30";"123345"Output of the code -Total Requests = NaNPeak Request = 139049 on "2019-09-17T19:44:00+05:30"Average request = NaNWhy NaN? I have gone over this for multiple times but can't solve this.
Submitted September 18, 2019 at 02:59PM by GhostFoxGod
No comments:
Post a Comment