Project: A Telemetry CLI Tool

Reading CSV from standard input, aggregating per sensor and reporting bad lines — a complete small program.

This project combines the course: structs with methods, a BTreeMap, iterators, pattern matching on slices, error handling and standard input/output. It reads sensor readings as CSV and prints statistics per sensor, the kind of small tool engineers write to analyse logs from test benches.

The program

Stats holds running totals; #[derive(Default)] provides the starting value for or_default().

lines().enumerate().skip(1) reads standard input line by line, skipping the header.

The match checks the shape (three fields) and that the value parses, in one pattern.

Invalid lines are collected and reported on standard error, so they do not mix with the results on standard output.

main returns io::Result<()> so the ? on reading a line works.

Extending it

Reading the whole input with read_to_string for large logs Process line by line with lines()

Streaming keeps memory use constant regardless of file size.

Why print errors with eprintln! instead of println!?

So diagnostics go to standard error and the real output on standard output can be piped or redirected cleanly (e.g. into another tool or a file).