Skip to content

Commit

Permalink
Review: use for loop starting at i = 1 to skip header row for perform…
Browse files Browse the repository at this point in the history
…ance
  • Loading branch information
lvancraen committed Jun 21, 2019
1 parent 40bdcdb commit edaa064
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions helpers/import.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,8 @@ Row: ${parsedRow.data[error.row].join(',')}`;
});
}

const [, ...rows] = parsedRow.data; // we don't need the header row, it's already stored in parsedKeys/trimmedKeys

rows.forEach((row) => {
for (let i = 1; i < parsedRow.data.length; i += 1) { // we only want to add to the table the remaining rows
const row = parsedRow.data[i];
const trimmedRow = row.map(value => value.trim());
if (trimmedRow !== null) {
const item = new GtfsRow(trimmedRow);
Expand All @@ -159,7 +158,7 @@ Row: ${parsedRow.data[error.row].join(',')}`;
table.add(item);
}
}
});
}
});

if (errorMessage && gtfs._shouldThrow) {
Expand Down

0 comments on commit edaa064

Please sign in to comment.