#试试开发table_config自动化
#输入
# 变量entity
#常量domain,conn_id
# with open("dy_table_config",encoding='utf-8') as f:
# data=f.readline()
# print(data)
import pandas as pd
entity=input("输入表名:")
s3_source_prefix=input("输入路径:")
list=['PRESTAGE.omt.TV_6_Profit_Center']
a1='{\n "domain": "new_rad_academy",\n'
b=' "entity": "'
c=entity
d='",\n '
d2='"file_inzip_pattern": "",\n'
d5=' "file_inzip_suffix": "",\n'
d3=' "standard_columns": "'
import openpyxl
path = r'C:\Testing_Tool\auto_package_v2_1110\Topic.xlsx'
#df=pd.read_excel('1.xlsx',sheet_name='student')#可以通过sheet_name来指定读取的表单
df=pd.read_excel(path,header=None)#这个会直接默认读取到这个Excel的第一个表单
data=df.iloc[0].values#0表示第一行 这里读
data3=','.join(data)
data4=data3.lower()
wb = openpyxl.load_workbook(path)
print(wb.sheetnames)
sheet=input("输入sheet名:")
d4='",\n '
da=' "is_archive": "N",\n'
db=' "is_exchange_merge": "false",\n'
dc=' "is_header": "true",\n'
dd=' "is_signal_file": "false",\n'
de=' "is_soft_fail": "true",\n'
de2=' "landing_file_format": "xlsx",\n'
df=' "merge_order_cols": "",\n'
dg=' "merge_order_sc": "desc",\n'
dh=' "primary_keys": "",\n'
dh2=' "redshift_enriched_post_job": "TRUNCATE TABLE '
for i in range(0,len(list)):
lista=list[i]
lista2=lista.strip()
listb=lista2.split('.')
listb2=listb[0].strip()
if listb2.upper()=='APPDDM':
s='analytical'+'_'+listb[0].strip()+'_'+listb[1].strip()+'.'+listb[2].strip()
elif listb2.upper()=='DW':
s='model' + '_' + listb[0].strip() + '_' + listb[1].strip() + '.' + listb[2].strip()
elif listb2.upper()=='DATAHUB':
s='ANALYTICAL' + '_' + listb[0].strip() + '_' + listb[1].strip() + '.' + listb[2].strip()
elif listb2.upper()=='MADW':
s='MODEL' + '_' + listb[0].strip() + '_' + listb[1].strip() + '.' + listb[2].strip()
elif listb2.upper()=='MART':
s='ANALYTICAL' + '_' + listb[0].strip() + '_' + listb[1].strip() + '.' + listb[2].strip()
elif listb2.upper()=='MARTPH':
s='ANALYTICAL' + '_' + listb[0].strip() + '_' + listb[1].strip() + '.' + listb[2].strip()
elif listb2.upper()=='MARTPHMA':
s='ANALYTICAL' + '_' + listb[0].strip() + '_' + listb[1].strip() + '.' + listb[2].strip()
elif listb2.upper()=='PRESTAGE':
s='ENRICHED' + '_' + listb[0].strip() + '_' + listb[1].strip() + '.' + listb[2].strip()
elif listb2.upper()=='STAGE':
s='ENRICHED' + '_' + listb[0] + '_' + listb[1].strip() + '.' + listb[2].strip()
else :
print("error")
dh3= s.lower()
dh4='",\n '
dh5='"replace_file_name": "",\n'
dh5a=' "s3_source_prefix": "'
dh6=s3_source_prefix
dh7='",\n '
dh8='"sheet_name": "'
dh9=sheet
dh10='",\n '
dh11='"skip_row": "0",\n'
dh12=' "source_file_pattern": "'
source_file_pattern=input("输入文件名:")
dh13=source_file_pattern
dh14='",\n '
dh15='"source_sensor_poke_interval": "60",\n'
dh16=' "source_sensor_retry_time": "1",\n'
dh17=' "source_system": "sftp_etl_ph_ctm_master",\n'
dh18='"state_machine_name": "ph-cdp-sm-workflow-cn-etl_ph_ctm_master"\n}'
with open('tdu.txt','w+') as f:
f.write(a1)
with open('tdu.txt','a') as f2:
f2.write(b)
with open('tdu.txt','a') as f2:
f2.write(c)
with open('tdu.txt','a') as f2:
f2.write(d)
with open('tdu.txt','a') as f2:
f2.write(d2)
with open('tdu.txt','a') as f2:
f2.write(d5)
with open('tdu.txt','a') as f2:
f2.write(da)
with open('tdu.txt','a') as f2:
f2.write(db)
with open('tdu.txt','a') as f2:
f2.write(dc)
with open('tdu.txt','a') as f2:
f2.write(dd)
with open('tdu.txt','a') as f2:
f2.write(de)
with open('tdu.txt','a') as f2:
f2.write(de2)
with open('tdu.txt','a') as f2:
f2.write(df)
with open('tdu.txt','a') as f2:
f2.write(dg)
with open('tdu.txt','a') as f2:
f2.write(dh)
with open('tdu.txt','a') as f2:
f2.write(dh2)
with open('tdu.txt','a') as f2:
f2.write(dh3)
with open('tdu.txt','a') as f2:
f2.write(dh4)
with open('tdu.txt','a') as f2:
f2.write(dh5)
with open('tdu.txt','a') as f2:
f2.write(dh5a)
with open('tdu.txt','a') as f2:
f2.write(dh6)
with open('tdu.txt','a') as f2:
f2.write(dh7)
with open('tdu.txt','a') as f2:
f2.write(dh8)
with open('tdu.txt','a') as f2:
f2.write(dh9)
with open('tdu.txt','a') as f2:
f2.write(dh10)
with open('tdu.txt','a') as f2:
f2.write(dh11)
with open('tdu.txt','a') as f2:
f2.write(dh12)
with open('tdu.txt','a') as f2:
f2.write(dh13)
with open('tdu.txt','a') as f2:
f2.write(dh14)
with open('tdu.txt','a') as f2:
f2.write(dh15)
with open('tdu.txt','a') as f2:
f2.write(dh16)
with open('tdu.txt','a') as f2:
f2.write(dh17)
with open('tdu.txt','a') as f2:
f2.write(d3)
with open('tdu.txt','a') as f2:
f2.write(data4)
with open('tdu.txt','a') as f2:
f2.write(d4)
with open('tdu.txt','a') as f2:
f2.write(dh18)
dydddddddd
最新推荐文章于 2024-05-20 22:54:06 发布