The Problem
Real data moment
This is a real excerpt from a genuinely public dataset — Chipotle order data, one of the most widely used first-CSV teaching sets, originally compiled from The New York Times' "What's on Your Chipotle Burrito?" and long maintained at justmarkham/DAT8 on GitHub:
order_id,quantity,item_name,choice_description,item_price
1,1,Chips and Fresh Tomato Salsa,NULL,$2.39
1,1,Izze,[Clementine],$3.39
2,2,Chicken Bowl,"[Tomatillo-Red Chili Salsa (Hot), [Black Beans, Rice, Cheese, Sour Cream]]",$16.98
3,1,Side of Chips,NULL,$1.69
Just lines of text, separated by commas. .csv doesn't stand for a file format the way .jpg does for images — it stands for a convention, and Course 01 already gave you every tool needed to read this by hand.
The gotcha
Add back the one row left out above — a real Chicken Bowl order, order 2 — and run the exact same code:
line = '2,2,Chicken Bowl,"[Tomatillo-Red Chili Salsa (Hot), [Black Beans, Rice, Cheese, Sour Cream]]",$16.98'
values = line.split(",")
print(len(values), values)
9 ['2', '2', 'Chicken Bowl', '"[Tomatillo-Red Chili Salsa (Hot)', ' [Black Beans', ' Rice', ' Cheese', ' Sour Cream]]"', '$16.98']
Nine fields, not five — choice_description's own real content contains commas, and split(",") has no way to know those commas are inside one field rather than separating five. Watch what dict(zip(header, values)) does with this:
header = ['order_id', 'quantity', 'item_name', 'choice_description', 'item_price']
row = dict(zip(header, values))
print(row)
{'order_id': '2', 'quantity': '2', 'item_name': 'Chicken Bowl', 'choice_description': '"[Tomatillo-Red Chili Salsa (Hot)', 'item_price': ' [Black Beans'}
No error. No crash. zip() silently stops at the shorter of its two inputs — five header names — and item_price quietly becomes ' [Black Beans' instead of the real '$16.98'. Any later calculation using this order's price would be wrong, with nothing in the output telling you so.
The fix is a real quoting convention, not a smarter split()
Real CSV writers wrap any field containing the delimiter in double quotes — exactly what you see around "[Tomatillo-Red Chili Salsa (Hot), ..." above. A correct parser has to track whether it's currently inside a quoted field before deciding a comma is a real separator. Python's own standard library already does this correctly:
import csv
line = '2,2,Chicken Bowl,"[Tomatillo-Red Chili Salsa (Hot), [Black Beans, Rice, Cheese, Sour Cream]]",$16.98'
print(next(csv.reader([line])))
['2', '2', 'Chicken Bowl', '[Tomatillo-Red Chili Salsa (Hot), [Black Beans, Rice, Cheese, Sour Cream]]', '$16.98']
Five fields, correctly split, quotes correctly stripped, item_price correctly intact as '$16.98'. Same real row, same real embedded commas — the only difference is using a parser that understands quoting instead of a bare split(",").
A third real row from this same dataset: 3,1,Chicken Bowl,"[Fresh Tomato Salsa (Mild), [Rice, Cheese, Sour Cream, Guacamole, Lettuce]]",$10.98. If this row is parsed with naive line.split(",") and dict(zip(header, values)), using the same 5-field header, what ends up in the resulting item_price value?
The comma-containing choice_description splits into 6 extra pieces beyond what 5 header fields expect, pushing everything after it two positions to the left. zip() silently stops once the shorter list (the 5-item header) runs out, so item_price ends up bound to whatever the 5th value in the split list happens to be — here, the fragment ' [Rice', not the real $10.98. No error is raised anywhere in this process, which is exactly what makes it dangerous: the code runs cleanly and produces a wrong answer.