def yield_public_companies() -> list: # TODO: SELECT MOST RECENT FILE IN THE FOLDER wrangled_folder_path = "finance_data_csv_wrangled" file_name = get_recent_file_name(wrangled_folder_path) df = pd.read_csv(f"{wrangled_folder_path}/{file_name}.csv") tot_public_companies = df["회사명"].to_list() print("Getting All Public Companies...") return tot_public_companies
def yield_kospi_companies() -> list: # TODO: SELECT MOST RECENT FILE IN THE FOLDER wrangled_folder_path = "finance_data_csv_wrangled" file_name = get_recent_file_name(wrangled_folder_path) df = pd.read_csv(f"{wrangled_folder_path}/{file_name}.csv") kospi_df = df.loc[df["코스피코스닥"] == "코스피"] kospi_companies = kospi_df["회사명"].to_list() print("Getting All KOSPI Companies...") return kospi_companies
def upload_to_gs(spreadsheet_id): # google spreadsheet API enabled credentials gc = gspread.service_account(filename="./credentials.json") """ # input google drive spreadsheet file name spinoff_google_sheets = gc.open("spinoff_data") print(spinoff_google_sheets.sheet1.get("A1")) """ recent_file_name = get_recent_file_name("_spinoff_data") content = open(f"_spinoff_data/{recent_file_name}.csv", "r").read() # using import_csv function from gspread gc.import_csv(spreadsheet_id, content.encode("utf-8")) return
print(df_spinoff_candidate) # save result as csv write_csv_folder_path = "_spinoff_data" df_spinoff_candidate.to_csv( f"{write_csv_folder_path}/{input_file_name}_spinoff.csv", encoding="utf-8", index=False, ) return if __name__ == "__main__": # Makes and wrangles the most recent excel file into csv file as same file name excel_folder_path = "finance_data_xlsx" csv_folder_path = "finance_data_csv" wrangled_folder_path = "finance_data_csv_wrangled" file_name = get_recent_file_name(excel_folder_path) make_xlsx_to_csv(file_name, excel_folder_path, csv_folder_path) wrangle_csv(file_name, csv_folder_path, wrangled_folder_path) # Makes spinoff company candidates csv file on ./_spinoff_data folder market = "KOSPI" search_keyword = "인적분할" main(market, search_keyword, file_name) # import csv file for the google spreadsheet google_spreadsheet_id = "1chJ2NKHVc0gKjsMaQI1UHEPxdjneV1ZWaTGHseQvxP4" upload_to_gs(google_spreadsheet_id)