From 13d7d0545ecd961d779bea1a5cb9c8714c1c6c04 Mon Sep 17 00:00:00 2001 From: Yam ZhengLim Date: Mon, 26 Sep 2022 19:42:02 +0800 Subject: [PATCH] add function into gen_func --- general_function.py | 7 ++++++- main.py | 7 +------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/general_function.py b/general_function.py index 177952d..a608ed4 100644 --- a/general_function.py +++ b/general_function.py @@ -20,4 +20,9 @@ def delete_csv_in_path(path): path = os.path.join(folder, file) print('deleted : ', path ) os.remove(path) - print("[Delete Temp Complete]",file) \ No newline at end of file + print("[Delete Temp Complete]",file) + + +def change_to_current_directory(): + script_dir = os.path.dirname(os.path.realpath(__file__)) + os.chdir(script_dir) \ No newline at end of file diff --git a/main.py b/main.py index c881c2e..bc24de0 100644 --- a/main.py +++ b/main.py @@ -38,15 +38,10 @@ def exchange_load_to_cloudstorage(EXCHANGE_CSV_TEMP_STORAGE_PATH): file_path = os.path.join(dirpath,file_name) ex_load_func.upload_to_bucket(ex_storage_client, file_name, file_path) -def linux_change_cron_directory(): - script_dir = os.path.dirname(os.path.realpath(__file__)) - print (os.getcwd()) - os.chdir(script_dir) def main(): #Make sure cron in the file directory - linux_change_cron_directory() - + general_function.change_to_current_directory() #Extract Load Exchange Data, and delete the temp csv EXCHANGE_CSV_TEMP_STORAGE_PATH = "./exchange/extract/exchange_temp_extract_csv/"