Beispiel #1
0
            #!mwd - I'm not sure how to do this. We link
            #  blocks by trip ids, but block ids are 
            #  random in gtfs, so we have no way to link
            #  them back

        except IOError, e:
            print >> sys.stderr, 'Unable to open trips.txt:', e

        # load all the stops
        try:
            f = open(os.path.join(directory, 'stop_times.txt'), 'rb')
            reader = csv.reader(f)

            mappings = {'arrival_time': ('arrival', lambda x: x),
                        'departure_time': ('departure', lambda x: x),
                        'stop_id': ('stop', lambda x: Stop.get_by_gtfs_id(x)),
            }

            # create a headers with an index
            headers = reader.next()
            r_headers = dict([(x, i) for i, x in enumerate(headers)])

            for l2 in reader:
                if len(l2) != len(headers):
                    print >> sys.stderr, 'Invalid line', l2, headers
                    continue
                
                kw = {}
                for i, a in enumerate(l2):
                    key = headers[i]
                    if key in mappings: