I have a csv and i am trying to convert certain data to integers when i parse the object it is still showing up in the console as a string.
d3.csv('somecsv.csv' function(response){
var data = response.map(function(item){
var newItem{};
newItem[parseInt("Column with spaces 1")] = item["Column with spaces 1"];
// This gives a Nan error
// even when i do
// newItem["Column with spaces 1"] = item["Column with spaces 1"];
// parseInt(newItem["Column with spaces 1"])
console.log(newItem)
// This displays a string. It never converted to an Int.
When i console.log the data is stored in an object that looks like this
Object { "Column with spaces 1": "99", "Column with spaces 2": "37" }
I want to convert it so it the value is a number not string
Object { "Column with spaces 1": 99, "Column with spaces 2": 37 }
newItem["Column with spaces 1"] = parseInt(item["Column with spaces 1"])and the same for the other property.Object.keys(item).forEach(key => newItem[key] = +item[key]). It handles all the keys.