From 3f2d91e7efa167f95b454f50ed23060961e50c98 Mon Sep 17 00:00:00 2001 From: Jian Shen Date: Tue, 23 Aug 2022 10:50:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=BB=B7=E6=A0=BC=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=E6=A3=80=E6=B5=8B=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dags/jh/price/price_exception.py | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/dags/jh/price/price_exception.py b/dags/jh/price/price_exception.py index 705d5e0..e3422c8 100644 --- a/dags/jh/price/price_exception.py +++ b/dags/jh/price/price_exception.py @@ -4,9 +4,14 @@ from goojia_utils import dateutils, oracle import pandas as pd import logging +import os log = logging.getLogger(__name__) +path = "/home/airflow/data/jh/price" +if not os.path.exists(path): + os.makedirs(path) + month_now = dateutils.format_date(dateutils.add_months(dateutils.datetime.datetime.now()), '%Y%m') month_last = dateutils.format_date(dateutils.add_months(dateutils.datetime.datetime.now(), months=-1), '%Y%m') month_before = dateutils.format_date(dateutils.add_months(dateutils.datetime.datetime.now(), months=-2), '%Y%m') @@ -49,7 +54,10 @@ for key in six_map: result_df = pd.DataFrame(actions) result_df['confidence'] = result_df['confidence'].astype(float) -excel_writer = pd.ExcelWriter('data/'+ month_now +'VS'+ month_last +'月价格波动大于10%小区.xlsx') +file_name = month_now +'VS'+ month_last +'月价格波动大于10%小区.xlsx' +aim_file_name = path + '/' + file_name + +excel_writer = pd.ExcelWriter(aim_file_name) result_df = result_df.drop_duplicates(subset=['commid'], keep='first') result_df = result_df.rename(columns={'city': '城市', 'region': '区域', 'commid': '小区ID', 'commname': '小区名', 'five_price': '上一月价格', @@ -66,3 +74,18 @@ city_count_df.to_excel(excel_writer, index=False, sheet_name='城市维度') excel_writer.save() excel_writer.close() + +def up_to_nextcloud(): + """ + 上传统计信息至nextcloud + """ + from nextcloud import NextCloud + NEXTCLOUD_URL = "https://nextcloud.fangjia.com" + NEXTCLOUD_USERNAME = "shenjian@fangjia.com" + NEXTCLOUD_PASSWORD = "goojia123456" + nextcloud_file_name = '共享/建行/' + file_name + nxc = NextCloud(endpoint=NEXTCLOUD_URL, user=NEXTCLOUD_USERNAME, password=NEXTCLOUD_PASSWORD, json_output=True) + nxc.upload_file(aim_file_name, nextcloud_file_name) + + +up_to_nextcloud()