Skip to main content

Checkpoint: the robust importer

Challenge on lesson: Checkpoint: The Robust Importer

Implement importRows(lines, errors, rows) that returns the number of imported rows. For every line index i (0-based): a blank line records "<i+1>: blank line"; wrong field count records "<i+1>: expected 2 fields, got N"; a non-numeric age records "<i+1>: bad age '<field>'"; an age outside 0..150 records "<i+1>: age out of range <age>"; an empty name records "<i+1>: empty name". Valid rows append new Row(name, age) (trimmed). Processing never stops early.

Difficulty: advanced

Back to lesson: Checkpoint: The Robust Importer