Python’s open() opens a named file and returns a file object that programs can use to access its contents. Reading is the default mode, so the optional 'r' argument is unnecessary. section 5.1.4
Open and inspect a CSV file
Assign the result to a variable, call readline() to retrieve one line, and use split(',') to separate columns. After processing, call close() to close the file. section 5.1.4
>>> nfl_file = open('nfl_offensive_stats.csv')
Shows the minimal Python expression for opening the NFL statistics file. section 5.1.4
A basic file-reading workflow is:
- Open the file and assign its file object to a variable. section 5.1.4
- Read lines, split their text into fields, and convert numeric fields when needed. section 5.1.4
- Close the file after processing; code using csv.reader can instead place open() inside a with statement. section 5.1.4








