I have a CSV file with data like this -
time,a,b,c,d,e,f,g
2020-06-18 14:59:34.585143,2,0,0,2,1,1,0
2020-06-18 14:59:38.302183,2,0,0,2,1,0,1
..
..
2020-06-18 15:04:11.529016,1,0,0,1,0,0,0
2020-06-18 15:04:11.874480,1,0,0,1,0,0,0
2020-06-18 15:04:12.213976,1,0,0,1,0,0,0
I am reading it using node-csv
package and sending it to Angular
based frontend to be later drawn on a chart using ChartJS
.
The chart looks ugly due to the density of data(every second).
I'm looking to round-off the data from the CSV which should be-
- From the last 6 hours from the latest entry.
- Should be rounded-off to 30 minutes with the aggregation of the corresponding values of a,b,c,d... from the CSV.
I think you need to create a custom parser, like in this answer.
And then create a key from the DateTime value so that it's rounded to every 30 minutes, so like "2020-06-18 14:59:34.585143" to key "202006181430", see example in this answer.