50 lines
1.4 KiB
Python
50 lines
1.4 KiB
Python
"""
|
|
This is a one-time fix script where we need to fix some content of the accounts created.
|
|
"""
|
|
|
|
# Imports:
|
|
import os
|
|
import pandas as pd
|
|
from tcaoff import tcaoff
|
|
from utils_v2.string import json
|
|
from utils_v2.system import files
|
|
|
|
# File paths:
|
|
file_dir = files.get_file_directory(include_filename = False)
|
|
proj_dir = files.get_parent_directory(file_dir, depth = 1)
|
|
tcaoff_creds_file = os.path.join(proj_dir, "creds", "tcaoff.json")
|
|
|
|
# Load the creds:
|
|
tcaoff_creds = json.from_file(tcaoff_creds_file)
|
|
|
|
# Log in:
|
|
tcaoff.login(tcaoff_creds)
|
|
|
|
# Load the team list:
|
|
team_list = tcaoff.team_list(tcaoff_creds)
|
|
|
|
# Loop through the list,
|
|
# check if `applicantNotes` in `json_notes` is a string,
|
|
# if it is a string, convert it to a dict/list and update the user:
|
|
for team in team_list:
|
|
|
|
# Extract info:
|
|
json_notes = json.from_string(team.get("json_notes", {}))
|
|
app_notes = json_notes.get("applicantNotes")
|
|
|
|
# If the app notes are a string, update them:
|
|
if isinstance(app_notes, str):
|
|
app_notes = json.from_string(app_notes)
|
|
json_notes["applicantNotes"] = app_notes
|
|
team["json_notes"] = json.to_string(json_notes, no_space = True)
|
|
|
|
# Make a pandas DataFrame:
|
|
team_df = pd.DataFrame(team_list)
|
|
|
|
# Log out:
|
|
tcaoff.logout(tcaoff_creds)
|
|
|
|
# Show and save the DF:
|
|
print(team_df[:10].to_string())
|
|
team_df[["user_id", "json_notes"]].to_csv(r"C:\Users\Khushal P Soonderji\Downloads\20260116_cosec_team_fix.csv", index = False)
|