score:0

You can do a check before creating the substring. something like this.

csv.Amount = csv.Amount || 'Your string when data is undefined';

and afterwards do the string manipulation.

score:2

I could be oversimplifying this, but isn't csv an array? So running csv.CheckDate.substring(1) would not make sense. Instead you'd want to loop through each member of the array and row.CheckDate.substring(1), etc.

Taking that into account, try this:

d3.csv("DATA2015.csv", function(csv) {
  csv.forEach(function(row) {
    row.CheckDate = row.CheckDate.substring(1);
    row.Amount = +row.Amount.substring(1);
    row.Fee = +row.Fee;
  });

  csv = csv.filter(function(row) {
    return row.Amount !== '';
  });

  console.log(csv[0]);
  console.log(csv[1]);
  console.log(csv[2]);
  console.log(csv[3]);
  console.log(csv[4]);
});

Related Query

More Query from same tag