def make_client_map(client_list: Sheet) -> Dict[str, str]: clients = client_list.col_values(1, 1) sales = client_list.col_values(3, 1) client_map = {} for i, client in enumerate(clients): sal = sales[i] if not sal: log('“{}”的业务员为空,归为“其他”'.format(client)) sal = '其他' ret = client_map.setdefault(client, sal) if ret != sal: log('“{}”同时属于“{}”和“{}”,自动归为“{}”'.format(client, ret, sal, ret)) return client_map
def __init__(self, route_table: Sheet): self.rt_idx = {} self.sc_idx = {} self.schools = {} # school: (route, abbr) routes = route_table.col_values(0) schools = route_table.col_values(1) assert len(schools) == len(routes) abbrs = route_table.col_values(2) assert len(abbrs) == len(schools) dist_route = set() for i, school in enumerate(schools): route, abbr = routes[i], abbrs[i] if (not school) or (not route) or (not abbr): stm = '不完整的记录:第{}行:“{} {} {}”,已丢弃' log(stm.format(i + 1, school, route, abbr)) else: self.schools[school] = (route, abbr) self.rt_idx.setdefault(route, len(self.rt_idx)) self.sc_idx.setdefault(school, len(self.sc_idx))