I have a CSV file I am working with. I don't want to convert it to an object to have keys and values. I want to be able to create more arrays to store different values I.e Temperature Hum hours snowDepth etc All these will be arrays with 7 values
Right now, this is how the csv is stored in the data array
- "11/28/2018 7:30,1128,-2.122,86.2,34.06,1.178,320.2,20.4"
- "11/28/2018 7:45,1129,-2.325,85.6,34.54,1.771,325.5,30.72"
- "11/28/2018 8:00,1130,-2.679,85.7,30.73,1.764,312.1,28.98"
- "11/28/2018 8:15,1131,-2.872,88,34.55,1.073,306.6,25.65"
- "11/28/2018 8:30,1132,-2.953,90.7,35.25,1.247,311.2,30.06"
- "11/28/2018 8:45,1133,-3.064,93.3,35,1.449,312.6,30.13"
- "11/28/2018 9:00,1134,-2.771,91.5,33.44,0.988,311,28.27" length: 7
the 1st col is the timestamp, 2nd is record number, 3rd is the temperature, 4th is the humidity and so on.
function get_Data(data) {
"use strict";
var fileData = new Array();
data = data.split(/\r\n|\r|\n/);
data = data.slice(Math.max(data.length - 7, 0));
createGraph(data);
}
I want arrays like this
Tem = [-2.122, -2.325, -2.679, -2.872 ...]
hours = [7:30, 7:45, 8:00, 8:15 ...]
i:values = arr.map(str => str.split(',')[i]). Lots of related questions: stackoverflow.com/search?q=%5Bjavascript%5D+parse+csv