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]:
In [ ]: