def load_stations(self): # Read excel file and create a list with station objects with open('StationsHolland.csv') as csv_file: csv_reader = csv.reader(csv_file, delimiter=',') stations = [] for row in csv_reader: stations.append(Station(row[0], row[1], row[2], row[3])) plt.plot(float(row[2]), float(row[1]), "bo") plt.text(float(row[2]) -0.02, float(row[1])+0.02, row[0], fontsize=5) return stations
def handling_requests(self, data): print "hereee" request = np.array(data.data) for i in range(0, len(request), 2): cart = Cart(request[i]) station = request_mapping[Station(request[i + 1])] self.directions_info[station] = cart self.requests.append(station) self.path_finder.publish_path(self.next_goal, self.requests)
def __init__(self, text): self.headers = HEADERS self.error = COMMEN_ERROR self.now_time = datetime.now().strftime('%Y%m%d') self.model = '' self.people_date = '' self.fast_model = fast_model self.slow_model = slow_model self.all_model = all_model self.station = Station() self.url = self.__get_query_url(text) self.trains_info = []
def read_file(): list_stations = [] with open('delhi-metro-stations') as csvfile: contents = csv.reader(csvfile) for i in contents: list_stations.append(''.join(i)) temp = 0 key = ' ' list = [] flag = True while flag: if '#' in list_stations[temp]: key = list_stations[temp] elif 'START' in list_stations[temp] or len(list_stations[temp]) == 0: flag = False else: list1 = [] list1.append(key) if 'Conn' not in list_stations[temp]: station = list_stations[temp].split(':') for i in station: list1.append(i) if len(list_stations[temp + 1]) == 0: list1.append('End') elif '#' not in list_stations[temp + 1]: list1.append(list_stations[temp + 1]) else: list1.append('End') list1.append('None') else: index = list_stations[temp].split(':Conn:') m_index = index[0].split(':') for i in m_index: list1.append(i) if len(list_stations[temp + 1]) == 0: list1.append('End') elif '#' not in list_stations[temp + 1]: list1.append(list_stations[temp + 1]) else: list1.append('End') list1.append(index[1]) list.append(list1) temp += 1 all_stations = [Station(i) for i in list] for i in all_stations: print(i._Tranfer)
"site_id": "ST4", 'location':"Vattiyoorkavu", "stype":"phc" }, { "site_name": "District Centre", "site_id": "ST5", 'location':"Trivandrum", "stype":"sc" } ] for s in stations: st = session.query(StationType).filter(StationType.code == s['stype']).first() l = session.query(Location).filter(Location.name == s['location']).first() s = Station(name=s['site_name'],code=s['site_id'],location_id=l.id,station_type_id=st.id) session.add(s) session.commit() role_stations = [ { 'center':'sc', 'roles': ["sc_user"] },{ 'center':'phc', 'roles': ["phc_user"] }] for rs in role_stations: st = session.query(StationType).filter(StationType.code == rs['center']).first() for role in rs['roles']: