In [2]:
#with open('/Users/ramz.sivagurunathan/hacks/hackathon/datasets/routes/parramatta_routes_regular.txt') as fp:
with open('/Users/ramz.sivagurunathan/hacks/hackathon/datasets/routes/parramatta_routes_train.txt') as fp:
    routes = [line.strip() for line in fp.readlines()]
routes = set(routes)

In [10]:
import csv
with open('/Users/ramz.sivagurunathan/hacks/hackathon/datasets/routes/shapes_paramatta_train.txt', 'wb') as outfile:
    writer = csv.writer(outfile)
    with open('/Users/ramz.sivagurunathan/hacks/hackathon/datasets/routes/shapes.txt', 'rb') as csvfile:
        shapes_data = csv.reader(csvfile)
        i = 0
        for row in shapes_data:
            shape_id = row[0]
            if shape_id in routes:
                writer.writerows([row])

In [36]:
import json

with open('/Users/ramz.sivagurunathan/hacks/hackathon/datasets/routes/shapes_paramatta.txt', 'rb') as fp:
    shapes_data = csv.reader(fp)
    route_dict = {}
    i = 0
    for row in shapes_data:
        route_info = route_dict.get(row[0], [])
        route_info.append([row[1], row[2]])
        i = i + 1
        route_dict[row[0]] = route_info
        
with open('/Users/ramz.sivagurunathan/hacks/hackathon/code/parramatta_route_path.json', 'wb') as fp:
    json.dump(route_dict, fp)

In [2]:
routes


Out[2]:
{'2-T1-C-sj2-1.1.R',
 '30-600-sj2-1.1.R',
 '30-601-sj2-1.1.R',
 '30-606-sj2-1.1.R',
 '30-609-sj2-1.1.R',
 '30-706-sj2-1.1.R',
 '30-708-sj2-1.1.R',
 '30-711-sj2-1.1.R',
 '30-T60-sj2-1.1.R',
 '30-T63-sj2-1.1.R',
 '30-T64-sj2-1.1.R',
 '30-T65-sj2-1.1.R',
 '30-T66-sj2-1.1.R',
 '41-900-sj2-1.1.R',
 '41-M91-sj2-1.1.R',
 '90-521-sj2-1.1.R',
 '90-523-sj2-1.1.R',
 '90-549-sj2-1.1.R',
 '90-550-sj2-1.1.R',
 '92-N71-sj2-1.1.R',
 '98-810-X-sj2-1.1.R',
 '98-810-sj2-1.1.R',
 '98-829-sj2-1.1.R'}

In [ ]: