Project: Test Results Report
Reading CSV from standard input, sealed result types for good and bad lines, and a grouped report.
This project reads hardware test results from standard input and prints a report per board, skipping malformed lines with a clear message. It combines data classes, a sealed type for parse results, sequences, grouping and formatted output.
The program
parse returns Ok or Bad (a sealed type), so every line is either a result or an explained error.
generateSequence(::readLine) reads standard input lazily until it ends; drop(1) skips the header.
filterIsInstance<Ok>() keeps the good results; groupBy and toSortedMap build the report.
Errors go to System.err so they do not mix with the report.
Extending it
Throwing an exception on the first bad line Collect errors as values (a sealed result type) and report them all
For data import tools, reporting every bad line at once saves repeated runs.
What does filterIsInstance<T>() do?
Keeps only the elements of type T and returns them typed as List<T>.