diff --git a/etl/MonthEndUploader.py b/etl/MonthEndUploader.py new file mode 100644 index 0000000..4a7231e --- /dev/null +++ b/etl/MonthEndUploader.py @@ -0,0 +1,21 @@ +import os +os.environ["SHAREPOINT_CLIENT_ID"] = "6832a4c5-fb8c-4082-a746-4f51e1020f0d" +os.environ["SHAREPOINT_CLIENT_SECRET"] = "xpC8Q~Frww48SM1V-D8lGy5iOY7P_cJ7FF3jgarQ" +os.environ["SHAREPOINT_TENANT_ID"] = "10d5af8b-2cfd-4882-9ccd-b96e4812dacf" +from etl.scraper.scraper import SharePointScraper, SharePointInstaller +import datetime + + +def upload_to_month_end_folder(file_name_on_sp, local_file_path): + sharepoint = SharePointScraper(SharePointInstaller.OSMOSIS_WAVE_2) + + parent_folder = "General/Junte Kim/month end" + today = datetime.today() + # Format as "Month YYYY" + formatted_date = today.strftime("%B %Y") + + sharepoint.create_dir(formatted_date, parent_folder) + sharepoint_path = parent_folder + "/" + formatted_date + print("Uploading to sharepoint...") + sharepoint.upload_file(local_file_path, sharepoint_path, file_name_on_sp) + print(f"Finished upload of {local_file_path} to sharepoint. It's found under {sharepoint_path}/{file_name_on_sp}") diff --git a/etl/month_end_automation_wave_2_layout.py b/etl/month_end_automation_wave_2_layout.py index 7dca011..22fe724 100644 --- a/etl/month_end_automation_wave_2_layout.py +++ b/etl/month_end_automation_wave_2_layout.py @@ -1,11 +1,13 @@ -# Wave 2's month end automation +# Wave 2's month end automation from tqdm import tqdm from monday import MondayClient from etl.osmosis_complaince_address_to_files import get_all_items, extract_asset_ids from pprint import pprint import pandas as pd import json +from MonthEndUploader import upload_to_month_end_folder + monday_key = "eyJhbGciOiJIUzI1NiJ9.eyJ0aWQiOjQ5ODc2ODQxOCwiYWFpIjoxMSwidWlkIjozNjE3ODAzNCwiaWFkIjoiMjAyNS0wNC0xMVQxMToyMzoxNy40NjdaIiwicGVyIjoibWU6d3JpdGUiLCJhY3RpZCI6MTM5OTc4MjMsInJnbiI6InVzZTEifQ.-2Lit4s46ZF6AXuMW9t0TxIaFLkHqD4Yo-PyM9i2XZY" monday = MondayClient(monday_key)