Parsing a CSV file with a simple string.split() was going along swimmingly…

for line in open("samples/sample.csv"):
    title, year, director = line.split(",")
    print year, title

…until I ran into a double-quoted string in the data file I was parsing. Thanks to Python’s CVS module (which I should have been using all along) all parsing activities are back to normal.

import csv
reader = csv.reader(open("samples/sample.csv"))
for title, year, director in reader:
    print year, title