diff --git a/mycode/main.py b/mycode/main.py index af7f6af..547c341 100644 --- a/mycode/main.py +++ b/mycode/main.py @@ -118,7 +118,6 @@ def get_cbma_info_from_db_and_ana(year: str = '2023'): try: conn_web = psycopg2.connect( "dbname={} user={} password={} host={} port={}".format('edn_cms', 'auditor', 'Lde78B3_cbma', '10.65.253.10', '54321')) - cur_web = conn.cursor() query_web = f""" SELECT a_outer.id, @@ -146,10 +145,9 @@ def get_cbma_info_from_db_and_ana(year: str = '2023'): a_outer.ctime; """ df_web = pd.read_sql_query(query_web, conn_web) - cur_web.close() conn_web.close() except Exception as e: - pass + print(e) # 追加总院数据来源 for ind, row in df.iterrows(): @@ -193,7 +191,7 @@ def get_cbma_info_from_db_and_ana(year: str = '2023'): # df_fx.at[ind, '供总院全年稿数'] = ((df['source'].str.contains(dw))&(df['gbiz']==zybiz)).sum() df_fx.at[ind, '供总院全年专稿数'] = ( (df['source'] == dw) & (df['gbiz'] == zybiz)).sum() - df_fx.at[ind, '供总院全年网站专稿数'] = ( + df_fx.at[ind, '供总院网站全年专稿数'] = ( (df_web['source'] == dw)).sum() df_fx.at[ind, '供总院全年组稿数'] = ((df['source'].str.contains( dw) & (df['source'] != dw)) & (df['gbiz'] == zybiz)).sum() @@ -290,11 +288,11 @@ def get_cbma_info_from_db_and_ana(year: str = '2023'): sheet_web.cell(row=1, column=1, value=f'关于{year}年度中国建材总院新媒体更新情况明细表\n(网站)') ind_zyweb = 0 for ind, row in df_web.iterrows(): - sheet.cell(row=ind_zy+3, column=1, value=str(ind_zyweb+1)) - sheet.cell(row=ind_zy+3, column=2, value=f'{row["pub_year"]}-{row["pub_month"]}-{row["pub_day"]}') - sheet.cell(row=ind_zy+3, column=3, value=row['title']) - sheet.cell(row=ind_zy+3, column=4, value=row['source']) - sheet.cell(row=ind_zy+3, column=5, value=row['bankuai']) + sheet_web.cell(row=ind_zyweb+3, column=1, value=str(ind_zyweb+1)) + sheet_web.cell(row=ind_zyweb+3, column=2, value=f'{row["pub_year"]}-{row["pub_month"]}-{row["pub_day"]}') + sheet_web.cell(row=ind_zyweb+3, column=3, value=row['title']) + sheet_web.cell(row=ind_zyweb+3, column=4, value=row['source']) + sheet_web.cell(row=ind_zyweb+3, column=5, value=row['bankuai']) ind_zyweb = ind_zyweb + 1 cbma_path = os.path.join(BASE_DIR, f'summary/{year}年_总院文章.xlsx') workbook.save(cbma_path) diff --git a/summary/template_cbma.xlsx b/summary/template_cbma.xlsx index 06b9964..c4dd569 100644 Binary files a/summary/template_cbma.xlsx and b/summary/template_cbma.xlsx differ diff --git a/summary/template_cbma_cal.xlsx b/summary/template_cbma_cal.xlsx index 3c0487a..9732e9d 100644 Binary files a/summary/template_cbma_cal.xlsx and b/summary/template_cbma_cal.xlsx differ diff --git a/summary/template_month.xlsx b/summary/template_month.xlsx index e7ec7f0..9dd54da 100644 Binary files a/summary/template_month.xlsx and b/summary/template_month.xlsx differ