1. import csv
    2. with open('stocks.csv') as f:
    3. f_csv = csv.reader(f)
    4. headers = next(f_csv)
    5. for row in f_csv:
    6. # Process row
    7. ...
    1. headers = ['Symbol', 'Price', 'Date', 'Time', 'Change', 'Volume']
    2. rows = [{'Symbol':'AA', 'Price':39.48, 'Date':'6/11/2007',
    3. 'Time':'9:36am', 'Change':-0.18, 'Volume':181800},
    4. {'Symbol':'AIG', 'Price': 71.38, 'Date':'6/11/2007',
    5. 'Time':'9:36am', 'Change':-0.15, 'Volume': 195500},
    6. {'Symbol':'AXP', 'Price': 62.58, 'Date':'6/11/2007',
    7. 'Time':'9:36am', 'Change':-0.46, 'Volume': 935000},
    8. ]
    9. with open('stocks.csv','w') as f:
    10. f_csv = csv.DictWriter(f, headers)
    11. f_csv.writeheader()
    12. f_csv.writerows(rows)