import sys
sys.path.append(r'D:\PycharmProjects\zzsn\base')
import BaseCore
baseCore = BaseCore.BaseCore()

import pandas as pd

r = baseCore.r
key = 'Nianbao:id'

df = pd.read_excel(r'D:\kkwork\企业数据\企业年报.xlsx')

def mian(key):
    while True:
        info = baseCore.redicPullData(key)

        # info = '91330281784320546U|'
        if info == None:
            break
        else:
            pass
        r.lpush('Nianbao:id_2', info)
        social_code = info.split('|')[0]
        # if df.loc[df['信用代码'] == social_code].astype(str).iloc[0]:
        try:
            row = df.loc[df['信用代码'] == social_code].astype(str).iloc[0]
            # 现在我们想要在这一行中追加一个新列，例如'新列名'，值为'新值'
            new_column_name = '系统中是否有年报'
            new_value = '2023'

            # 在DataFrame中追加新列
            df.loc[df['信用代码'] == social_code, new_column_name] = new_value
        except:
            continue

        # break
    df.to_excel(r'D:\kkwork\企业数据\企业年报.xlsx', index=False)
    print('完成')

if __name__ == '__main__':
    mian(key)
