Topic 11
Topic 11
Ruby source files are converted directly from the English source tree.
Overview
Why this topic matters ๐ก
CSV work appears constantly in business software: imports, exports, admin reports, and integration handoffs. This topic teaches students to treat CSV handling as a small data pipeline: read data, write data, then query it in a focused service.
Learning outcomes ๐ฏ
By the end of this topic, students should be able to:
Assessment focus โ
Students should be able to explain why file access and query logic should not be mixed into one large method.
Short Note
Students often first see CSV as a utility task: "open a file and loop over lines." That is too narrow. CSV work usually has three separate concerns:
Ruby is pleasant here because:
Ruby beauty in this topic:
Ruby caution in this topic:
Reflection prompt:
Worked Examples
Example 1: Importing inventory from a CSV file ๐ก
An inventory import is a strong teaching example because the file structure is easy to understand and the result maps naturally to arrays of hashes.
reader . load ( "inventory.csv" ) # => [{ "sku" => "B100" , "name" => "Ruby Book" , "price" => "30" , "category" => "books" }] worked_examples.md ruby This is a good first sprint because it isolates file reading from later business logic.
Example 2: Querying imported rows ๐ก
Once rows are loaded, teams usually ask questions like:
Why this is useful: