美团中间表改造

This commit is contained in:
shenjian@fangjia.com
2023-03-20 11:38:48 +08:00
parent 11d76204a7
commit 7c99f1b0ac
6 changed files with 82 additions and 14 deletions
+8 -3
View File
@@ -1,13 +1,14 @@
"""
小区属性导出
"""
from goojia_utils import MAIN_MONGO_CLIENT, dateutils, commutils
from goojia_utils import MAIN_MONGO_CLIENT, dateutils, commutils, ClickHouseClient
import pandas as pd
import datetime
import os
import sys
seaweed_conn = MAIN_MONGO_CLIENT.get_collection('fangjia', 'seaweed')
tmp_ck = ClickHouseClient(database='tmp')
path = "/home/airflow/data/mt"
if not os.path.exists(path):
@@ -74,5 +75,9 @@ seaweed_new_result_df = seaweed_new_result_df.rename(columns={'_id': 'id', 'mapp
'cubage_percent' : 'plot_ratio', 'virescence_percent': 'landscaping_ratio', 'estate_type2': 'property_type',
'main_type': 'house_type', 'main_type_area': 'house_area'})
seaweed_new_result_df.to_csv(path + '/FJW_COMM_' + output_date + '.csv',
sep='@', encoding='utf-8', index=False)
seaweed_new_result_df.to_csv(path + '/FJW_COMM_' + output_date + '.csv', sep='@', encoding='utf-8', index=False)
ck_delete_sql = "ALTER TABLE tmp.mt_community DELETE WHERE 1=1 "
tmp_ck.execute(ck_delete_sql)
tmp_ck.to_sql_plus(seaweed_new_result_df, 'mt_community')