
Predict
The Header Changed
One week, a keeper rearranged the columns in their spreadsheet. This program reads the columns by position, not by name.
import csv, io
week1 = "id,qty,price\nA1,3,10\n"
week2 = "id,price,qty\nB1,20,5\n"
total = 0
for text in [week1, week2]:
rows = list(csv.reader(io.StringIO(text)))
for row in rows[1:]: # skip the header
total += int(row[1]) # column 1 is qty?
print(total)