Found a solution that might work, apply slice directly in nodes. I am still a little worried that indexes might mismatch or something.

}).then(function(data, i) {


Note, that d3.csv() internally uses d3.csvParse()—which itself is only a tiny wrapper around d3.dsvParse()—for parsing the rows of the fetched file. The docs on the latter method have got you covered:

If the returned value is null or undefined, the row is skipped and will be omitted from the array returned by dsv.parse; otherwise, the returned value defines the corresponding row object.

For your code this could be something along the following lines:

var impt = d3.csv("Data/prisoncsv8.csv", function(data, i) {
  return i < datastart || i > dataend
    ? null   // Skip lines outside the range [datastart, dataend].
    : {      // Normal conversion for all lines to included.
      //more data here in the following format
      "id": i,
      "stage": 1,
      "columntitle": data.columntitle
}).then(function(data, i) {
  // ...

Related Query

More Query from same tag