Exemplo n.º 1
0
    def out_as_csv(self, filename):
        print(len(self.gbid_dic))
        newdir = utils.get_dir('out')
        out_name = os.path.join(newdir, filename)

        days_list = list(self.days.keys())
        days_list.sort()
        csv = csv_output.CSVOutPut()
        for i, day in enumerate(days_list):
            day_dict = self.days[day]
            dur_dict = {}
            csv.set(0, i * 2, day)
            csv.set(0, i * 2 + 1, day)
            for uk, lo in day_dict.items():
                dur_dict[lo.get_duration()] = dur_dict.get(
                    lo.get_duration(), 0) + 1

            dur_list = list(dur_dict.keys())
            dur_list.sort()
            for j in range(121):
                csv.set(j + 1, i * 2, j)
                csv.set(j + 1, i * 2 + 1, dur_dict.get(j, 0))

            # for j, dur in enumerate(dur_list):
            #     count = dur_dict[dur]
            #     csv.set(j + 1, i * 2, dur)
            #     csv.set(j + 1, i * 2 + 1, count)

        csv.output(out_name)
Exemplo n.º 2
0
def guide_flow():
    fname = utils.filter_from_origin('GuideFlow')
    id_dic = {}
    avatar_count = utils.get_avatar_count()
    with utils.utf8_open(fname) as fr:
        for line in fr:
            lo = LogOne.get_log_from_line(line)
            if not lo:
                continue
            
            id_dic.setdefault(lo.guide_id, set())
            id_dic[lo.guide_id].add(lo.gbid)
    
    rets = [(int(k), len(v)) for k, v in id_dic.items()]
    rets.sort(key=lambda x: x[0])
    csv = csv_output.CSVOutPut()
    csv.set(0, 0, '节点')
    csv.set(0, 1, '创角数')
    csv.set(0, 2, '节点通过人数')
    csv.set(0, 3, '节点通过率')
    idx = 1
    for key, num in rets:
        csv.set(idx, 0, key)
        csv.set(idx, 1, avatar_count)
        csv.set(idx, 2, num)
        csv.set(idx, 3, num / avatar_count)
        idx += 1
        
    out_name = utils.get_out_name('out', 'guide_flow.csv')
    csv.output(out_name)
Exemplo n.º 3
0
def parse_today_not_login():
    fname = log_one_utils.get_login_out_log_new()
    avatar_dic = {}
    with utils.utf8_open(fname) as fr:
        for line in fr:
            lo = LogOne.get_log_from_line(line)
            if not (const.FIRST_DAY <= lo.day <= const.FINAL_DAY):
                continue
            uk = lo.unique_key()
            if uk in avatar_dic:
                avatar_dic[uk].add_log(lo)
            else:
                avatar_dic[uk] = Avatar(uk, lo.level, lo.battle_point, lo)

    print(len(avatar_dic))
    csv = csv_output.CSVOutPut()
    csv.set(0, 0, 'GOPENID')
    csv.set(0, 1, '等级')
    csv.set(0, 2, '战力')
    csv.set(0, 3, '渠道号')
    idx = 1
    for av in avatar_dic.values():
        if 22 <= av.level <= 35 and (const.FINAL_DAY not in av.days):
            csv.set(idx, 0, f'{av.open_id}')
            csv.set(idx, 1, av.level)
            csv.set(idx, 2, av.battle_point)
            csv.set(idx, 3, av.login_channel)
            idx += 1
        
    fname = utils.get_out_name('out', 'today_not_login.csv')
    csv.output(fname)
Exemplo n.º 4
0
def get_openid_info_by_txt():
    # 根据openids.txt提供特定玩家信息
    avatar_dic = get_avatar_dic()
    csv = csv_output.CSVOutPut()
    csv.set(0, 0, 'openid')
    csv.set(0, 1, '次留')
    csv.set(0, 2, '三留')
    csv.set(0, 3, '七留')
    csv.set(0, 4, '首周登录天数')
    csv.set(0, 5, '战力')
    csv.set(0, 6, '等级')
    csv.set(0, 7, '哪一天登陆')
    idx = 0
    with utils.utf8_open(const.OPEN_IDS_TXT) as fr:
        for line in fr:
            idx += 1
            line = line.strip()
            if line in avatar_dic:
                a = avatar_dic[line]
                csv.set(idx, 0, line)
                csv.set(idx, 1, 1 if a.is_stay_by(1) else 0)
                csv.set(idx, 2, 1 if a.is_stay_by(2) else 0)
                csv.set(idx, 3, 1 if a.is_stay_by(6) else 0)
                csv.set(idx, 4, len(a.days))
                csv.set(idx, 5, a.battle_point)
                csv.set(idx, 6, a.level)
                csv.set(idx, 7, '|'.join(map(str, a.days)))

            else:
                print(line)
    out_name = utils.get_out_name('out', 'avatar_info_by_open_id_txt.csv')
    csv.output(out_name)
Exemplo n.º 5
0
def parse_tlog():
    avatar_dic = get_avatar_dic()
    school_dic = {}
    for uk, avatar_val in avatar_dic.items():
        if not hasattr(avatar_val, 'school'):
            print('error not has school:', avatar_val.open_id,
                  avatar_val.create_from)
            continue
        school_dic.setdefault(avatar_val.school, {})
        school_dic[avatar_val.school][uk] = avatar_val

    csv = csv_output.CSVOutPut()
    schools = list(school_dic.keys())
    # 总的次留
    ret_list = get_stay_list(avatar_dic, True)
    for ii, stay in enumerate(ret_list):
        csv.set(ii + 1, 1, stay)

    # 根据职业的次留
    for index, school in enumerate(schools):
        csv.set(0, index + 2, school)
        stay_list = get_stay_list(school_dic[school], True)
        for _index, stay in enumerate(stay_list):
            csv.set(_index + 1, index + 2, stay)

    for i in range(utils.get_whole_days()):
        csv.set(i + 1, 0, f'{i + 1}留')

    out_name = utils.get_out_name('out', 'school.csv')
    csv.output(out_name)
Exemplo n.º 6
0
    def out_school_csv(self, filename):
        csv = csv_output.CSVOutPut()

        schools = set(utils.get_gbid_school_dict().values())
        school_dict = {}
        for uk, lo in self.uk_dict.items():
            school_dict.setdefault(lo.school, {})
            school_dict[lo.school][uk] = lo

        for index, school in enumerate(schools):
            csv.set(0, index, school)
            csv.set(1, index, len(school_dict[school]))

            stay_1 = 0
            for lo in school_dict[school].values():
                if lo.is_stay_by_dur(1):
                    stay_1 += 1

            stay_2 = 0
            for lo in school_dict[school].values():
                if lo.is_stay_by_dur(2):
                    stay_2 += 1

            csv.set(2, index, stay_1)
            csv.set(3, index, stay_2)

        for k, v in school_dict.items():
            print(k, len(v))
        csv.output(filename)
Exemplo n.º 7
0
def get_header():
    dic = {}
    fname = utils.filter_from_origin('PlayerLogout')
    with utils.utf8_open(fname) as fr:
        for line in fr:
            lo = LogOne.get_log_from_line(line)
            if not lo:
                continue

            uk = lo.unique_key()
            if uk in dic:
                dic[uk].update_level(lo.level, lo.battle_point)
            else:
                dic[uk] = NewBieLeft(uk, lo.level, lo.login_channel,
                                     lo.battle_point)

    csv = csv_output.CSVOutPut()
    csv.set(0, 0, 'GOPENID')
    csv.set(0, 1, '等级')
    csv.set(0, 2, '战力')
    csv.set(0, 3, '渠道号')
    idx = 1
    for lo in dic.values():
        if lo.level > const.MAX_LEFT_LEVEL:
            continue

        csv.set(idx, 0, f'{lo.open_id}\'')
        csv.set(idx, 1, lo.level)
        csv.set(idx, 2, lo.battle_point)
        csv.set(idx, 3, lo.login_channel)
        idx += 1

    fname = utils.get_out_name('out', 'left_newbie_header.csv')
    csv.output(fname)
Exemplo n.º 8
0
    def out_as_csv(self, filename):
        out_dir = utils.get_dir('out')
        out_name = os.path.join(out_dir, filename)

        csv = csv_output.CSVOutPut()
        index = 0
        for day, day_dict in self.uk_day_dict.items():
            sum_score = sum(day_dict.values())
            csv.set(0, index, day)

            csv.set(1, index, sum_score / len(day_dict))
            csv.set(2, index, sum_score)
            csv.set(3, index, len(day_dict))
            index += 1

        csv.output(out_name)
Exemplo n.º 9
0
def bandit_boss():
    fname = log_one_utils.filter_resource_flow_by_src(65)
    days = {}
    with utils.utf8_open(fname) as fr:
        for line in fr:
            lo = LogOne.get_log_from_line(line)
            if lo.count != 200:
                continue

            days.setdefault(lo.day, set())
            days[lo.day].add(lo.unique_key())

    csv = csv_output.CSVOutPut()
    csv.set(0, 0, '日期')
    csv.set(1, 0, '人数')
    day_list = list(days.keys())
    day_list.sort()
    for idx, day in enumerate(day_list):
        csv.set(0, idx + 1, day)
        csv.set(1, idx + 1, len(days[day]))

    fw_name = utils.get_out_name('out', 'bandit_boss.csv')
    csv.output(fw_name)
Exemplo n.º 10
0
def get_avatar_login_5_days():
    # 获得登陆五天的玩家的相关信息
    avatar_dic = get_avatar_dic()
    csv = csv_output.CSVOutPut()
    csv.set(0, 0, 'OPENID')
    csv.set(0, 1, '等级')
    csv.set(0, 2, '战力')
    csv.set(0, 3, '渠道号')
    csv.set(0, 4, '登陆天')
    idx = 1
    for avatar_val in avatar_dic.values():
        if len(avatar_val.days) < 5:
            continue

        csv.set(idx, 0, avatar_val.open_id)
        csv.set(idx, 1, avatar_val.level)
        csv.set(idx, 2, avatar_val.battle_point)
        csv.set(idx, 3, avatar_val.channel)
        csv.set(idx, 4, '|'.join(map(str, (avatar_val.days))))
        idx += 1

    out_name = utils.get_out_name('out', 'login_5_days.csv')
    csv.output(out_name)
Exemplo n.º 11
0
    def out_as_csv(self, filename):
        csv = csv_output.CSVOutPut()
        out_name = os.path.join(utils.get_dir('out'), filename)
        day_list = list(self.days.keys())
        day_list.sort()

        for index, day in enumerate(day_list):
            csv.set(0, index * 2, str(day))
            csv.set(0, index * 2 + 1, str(day))
            day_dict = self.days[day]
            levelDict = {}
            for unique_key, lo in day_dict.items():
                levelDict.setdefault(lo.level, [])
                levelDict[lo.level].append(lo)

            levelList = list(levelDict.keys())
            levelList.sort()

            for _index, level in enumerate(levelList):
                num = len(levelDict[level])
                csv.set(_index + 1, index * 2, str(level))
                csv.set(_index + 1, index * 2 + 1, str(num))

        csv.output(out_name)