Beispiel #1
0
for row in stopsReader:
    try:
        stops.append({
            'stopId': int(row['stop_id']),
            'stopName': row['stop_name'],
            'location': [float(row['stop_lon']), float(row['stop_lat'])]
        })
    except ValueError:
        pass
print str(len(stops)) + " stops"
db.insertStops(stops, curDate)

routes = []
routesReader = DictReader(zipFile.open("routes.txt"))
for row in routesReader:
    try:
        row['route_id'] = int(row['route_id'])
        routes.append(row)
    except ValueError:
        pass
print str(len(routes)) + " routes"
db.insertRoutes(routes, curDate)

print "Generating Destinations Collection"
destinations = []
for trip in db.getFinalStops(curDate):
    destinations.append({ 'tripId': trip['_id'],
                          'stopName': db.getStopName(trip['stopId'], curDate) })
print str(len(destinations)) + " destinations"
db.insertDestinations(destinations, curDate)
Beispiel #2
0
    try:
        stops.append(
            {
                "stopId": row["stop_id"],
                "stopName": row["stop_name"],
                "location": [float(row["stop_lat"]), float(row["stop_lon"])],
            }
        )
    except ValueError:
        pass
print str(len(stops)) + " stops"
db.insertStops(stops, curDate)

routes = []
routesReader = DictReader(zipFile.open("routes.txt"))
for row in routesReader:
    try:
        row["route_id"] = int(row["route_id"])
        routes.append(row)
    except ValueError:
        pass
print str(len(routes)) + " routes"
db.insertRoutes(routes, curDate)

print "Generating Destinations Collection"
destinations = []
for trip in db.getFinalStops(curDate):
    destinations.append({"tripId": trip["_id"], "stopName": db.getStopName(trip["stopId"], curDate)})
print str(len(destinations)) + " destinations"
db.insertDestinations(destinations, curDate)