#!env/bin/python
import csv
from bus import get_directions

routes = []
with open('bus_routes.csv', 'rb') as csvfile:
    reader = csv.reader(csvfile)
    for row in reader:
        routes.append(row[0])

directions = []
for route in routes:
    for row in get_directions(route):
        directions.append({'route_num': route, 'direction': row})

keys = directions[0].keys()
with open('bus_directions.csv', 'wb') as output_file:
    writer = csv.DictWriter(output_file, keys)
    writer.writeheader()
    writer.writerows(directions)
