Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Read CSV file into lists

import sys
import csv

if len(sys.argv) != 2:
    sys.stderr.write("Usage: {} FILENAME\n".format(sys.argv[0]))
    exit()

filename = sys.argv[1]
with open(filename) as fh:
    rd = csv.reader(fh)

    for row in rd:
        print(row)

python examples/csv/read_csv.py  example/snowwhite.csv