Week 8: File I/O and CSV Processing
216 words
1 min read
Visual companion
Python
Type and operator map
Python Week 1: the first filter for runtime behavior
View
Revision summary
What this note is really saying
Short form
# Week 8: File I/O and CSV Processing > **Course:** Jan 2026 - Python > **Focus:** Reading structured data, transforming rows, and writing safe outputs. --- ## 1.

Visual strip
Relevant recall pieces for this note
Week 8: File I/O and CSV Processing
Course: Jan 2026 - Python Focus: Reading structured data, transforming rows, and writing safe outputs.
1. Core idea
Week 8 turns Python into a file processor: open, read, parse, transform, write, close.
What to remember
- Skip headers when the first line is metadata.
line.strip().split(',')is the usual CSV pattern for this course.- Convert numeric text to
intbefore arithmetic. readline()reads one line; iterating over the file walks the rest.- Always close files.
2. Common traps
- Forgetting the header changes the answer.
- Forgetting type conversion gives string math bugs.
- Writing filtered rows requires preserving the original row format carefully.
- The questions often ask for an average, a filtered subset, or a transformed file.
3. Speedrun pattern
When you see a Week 8 question, ask:
- Am I reading, filtering, aggregating, or writing?
- Which columns are numeric?
- Do I need the header line in the output?
4. Micro revision
open(..., 'r')readsopen(..., 'w')writessplit(',')parses CSV rowsreplace()can remove or rewrite columns
Assignment anchor
Navigation
- Previous: Week 7 Notes
- Next: Week 9 Notes