A data file stores information that a program can read, process, or produce. Python opens a file before reading it, then uses methods such as readline or a loop to access its lines. section 5.1.4 section 5.3
A typical file-reading task follows these steps:
- Open the file with open, optionally specifying read mode. section 5.1.4
- Read one line with readline or process every line with a for loop. section 5.1.4 section 5.3
- Split comma-separated lines into columns, convert numeric values when needed, and close the file afterward. section 5.1.4
Summing NFL passing yards
Read nfl_offensive_stats.csv, keep rows whose position is QB, add each quarterback’s passing yards to a dictionary, and print players in descending order. The csv module offers an alternative that reads rows without manually splitting strings. section 5.1.4







