Im trying accept user input and then if it matches the first value in a row of my csv push that entire row to an array.
I have a csv that looks like this.
City,Lat,Lon,Date
Seattle,47.6,122.3,2015 06 03
Spokane, 47.65, 117.42,2015 06 04
I accept user input like this.
var city = window.prompt("Which city are looking for",);
console.log(city);
Then if the city the user entered matches a city in the csv I want to push it to a new array. Here is the code I wrote for it, but its not quite working.
d3.csv("./some.csv", function(data) {
var lst = [];
for (var i = 0; i < data.length; i++){
if (data.City[i] == 'city') {
lst.push(data[i]);
}
console.log(lst);
}
});
My desired output would look something like this.
[['Seattle',47.6,122.3,2015 06 03],
['Seattle',47.6,122.3,2015 06 05]]
Any suggestions would be greatly appreciated.