feat:下田さんのレビュー指摘修正
This commit is contained in:
parent
7a8700ac3e
commit
9709ba1180
@ -24,7 +24,7 @@ SETTINGS_ITEM = {
|
|||||||
'storageSchemaName': 9,
|
'storageSchemaName': 9,
|
||||||
'loadSchemaName': 10,
|
'loadSchemaName': 10,
|
||||||
'exSqlFileName': 11,
|
'exSqlFileName': 11,
|
||||||
'replaceCommas': 12,
|
'commaReplaceColumns': 12,
|
||||||
'reserved0': 13,
|
'reserved0': 13,
|
||||||
'reserved1': 14,
|
'reserved1': 14,
|
||||||
'reserved2': 15,
|
'reserved2': 15,
|
||||||
@ -92,7 +92,7 @@ def main(bucket_name, target_data_source, target_file_name, settings_key, db_inf
|
|||||||
for line in io.TextIOWrapper(io.BytesIO(settings_response["Body"].read()), encoding='utf-8'):
|
for line in io.TextIOWrapper(io.BytesIO(settings_response["Body"].read()), encoding='utf-8'):
|
||||||
settings_list.append(line.rstrip('\n'))
|
settings_list.append(line.rstrip('\n'))
|
||||||
|
|
||||||
# 予約行挿入のためsetting_listとSETTINGS_ITEMの要素数を揃える
|
# 設定ファイルに記載のない行を空文字として扱い、予約行とする
|
||||||
for _ in range(len(SETTINGS_ITEM) - len(settings_list)):
|
for _ in range(len(SETTINGS_ITEM) - len(settings_list)):
|
||||||
settings_list.append('')
|
settings_list.append('')
|
||||||
|
|
||||||
@ -115,7 +115,7 @@ def main(bucket_name, target_data_source, target_file_name, settings_key, db_inf
|
|||||||
warning_info = '' # ワーニング情報
|
warning_info = '' # ワーニング情報
|
||||||
index = 0 # ループインデックス
|
index = 0 # ループインデックス
|
||||||
settings_db_columu_list = settings_list[SETTINGS_ITEM["dbColumuName"]].rstrip().split(',')
|
settings_db_columu_list = settings_list[SETTINGS_ITEM["dbColumuName"]].rstrip().split(',')
|
||||||
settings_replace_comma_list = settings_list[SETTINGS_ITEM["replaceCommas"]].rstrip().split(',')
|
settings_replace_comma_list = settings_list[SETTINGS_ITEM["commaReplaceColumns"]].rstrip().split(',')
|
||||||
|
|
||||||
for line in csv.reader(work_data, quotechar=settings_list[SETTINGS_ITEM["quotechar"]], delimiter=settings_list[SETTINGS_ITEM["delimiter"]]):
|
for line in csv.reader(work_data, quotechar=settings_list[SETTINGS_ITEM["quotechar"]], delimiter=settings_list[SETTINGS_ITEM["delimiter"]]):
|
||||||
try:
|
try:
|
||||||
@ -147,7 +147,9 @@ def main(bucket_name, target_data_source, target_file_name, settings_key, db_inf
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
# データ項目値の変換処理
|
# データ項目値の変換処理
|
||||||
column_value = replace_column_value(line,settings_db_columu_list,settings_replace_comma_list,i)
|
org_column_value = line[i]
|
||||||
|
current_settings_db_columu_name = settings_db_columu_list[i]
|
||||||
|
column_value = convert_column_value(org_column_value,current_settings_db_columu_name,settings_replace_comma_list)
|
||||||
sql = f'{sql} "{column_value}",'
|
sql = f'{sql} "{column_value}",'
|
||||||
|
|
||||||
sql = f'{sql} "{target_file_name}",' # システム項目:取込ファイル名
|
sql = f'{sql} "{target_file_name}",' # システム項目:取込ファイル名
|
||||||
@ -291,13 +293,14 @@ def connection_close(conn, bucket_name, target_data_source, target_file_name, lo
|
|||||||
print(f'{datetime.now():%Y-%m-%d %H:%M:%S} {log_info} {LOG_LEVEL["e"]} E-MAIN-99 - エラー内容:{e}')
|
print(f'{datetime.now():%Y-%m-%d %H:%M:%S} {log_info} {LOG_LEVEL["e"]} E-MAIN-99 - エラー内容:{e}')
|
||||||
error(bucket_name, target_data_source, target_file_name, log_info)
|
error(bucket_name, target_data_source, target_file_name, log_info)
|
||||||
|
|
||||||
def replace_column_value(line,settings_db_columu_list,settings_replace_comma_list,i):
|
def convert_column_value(org_column_value,current_settings_db_columu_name,settings_replace_comma_list):
|
||||||
org_column_value = line[i]
|
|
||||||
|
|
||||||
# 投入データのDB物理カラム名が設定ファイルの数値型のDBカラム物理名に含まれている場合
|
# データ内の「\\」という文字がpythonで読んだ場合に「\\\\」となるため、「\\」に戻す
|
||||||
if settings_db_columu_list[i] in settings_replace_comma_list:
|
converted_column_value = org_column_value.replace('\\', '\\\\')
|
||||||
org_column_value = org_column_value.replace(',', '')
|
|
||||||
|
# 投入データのDB物理カラム名が設定ファイルの数値型のDBカラム物理名に含まれている場合、データ項目値の「,」を取り除く
|
||||||
|
if current_settings_db_columu_name in settings_replace_comma_list:
|
||||||
|
converted_column_value = converted_column_value.replace(',', '')
|
||||||
|
|
||||||
org_column_value = org_column_value.replace('\\', '\\\\')
|
return converted_column_value
|
||||||
return org_column_value
|
|
||||||
|
|
||||||
@ -10,4 +10,4 @@ billing_type,condition_type,distribution_channel,invoiced_number,invoice_item,in
|
|||||||
src03b.sapf_invoice
|
src03b.sapf_invoice
|
||||||
org03b.sapf_invoice
|
org03b.sapf_invoice
|
||||||
|
|
||||||
vbl_value
|
quantity_invoiced,extended_amount_invoiced_amount,accrual_value_rebate_1,accrual_percent_rebate_1,accrual_value_rebate_2,accrual_percent_rebate_2,unit_selling_price
|
||||||
Loading…
x
Reference in New Issue
Block a user