Resetting utils subtree.
This commit is contained in:
@@ -41,6 +41,7 @@ import io
|
||||
# My utils:
|
||||
from utils_v2.string import json
|
||||
from utils_v2.string import regex
|
||||
from utils_v2.string import fuzzy
|
||||
from utils_v2.system import files
|
||||
from utils_v2.date_time import date_time
|
||||
from utils_v2.database.async_mysql_v2 import AsyncMySQL
|
||||
@@ -307,6 +308,7 @@ async def main(debug: bool = False):
|
||||
no_context_printer("Reading Excel.")
|
||||
activity_df = pd.read_excel(r"/home/developer/Downloads/Telegram Desktop/TaskManager - Edited.xlsx", sheet_name = "Activity")
|
||||
printer(len(activity_df))
|
||||
printer(activity_df["Department"].unique().tolist())
|
||||
|
||||
# Get a list of all the users:
|
||||
no_context_printer("Listing all users.")
|
||||
@@ -338,12 +340,36 @@ async def main(debug: bool = False):
|
||||
no_context_printer("Adding client id to Excel.")
|
||||
activity_df["client_id"] = activity_df["Client Name"].apply(lambda x: clients_by_name.get(x, {}).get("account_id", None))
|
||||
|
||||
# Apply fuzzy matching to get nearest options:
|
||||
no_context_printer("Fuzzy Usernames.")
|
||||
unique_new_users = list(users_by_pseudonym.keys())
|
||||
activity_df["Fuzzy Username"] = activity_df["Username"].apply(lambda x: fuzzy.get_best_match(target = x, choices = unique_new_users, threshold = 0.5, partial = False))
|
||||
no_context_printer("Fuzzy Client Names.")
|
||||
unique_new_clients = list(clients_by_name.keys())
|
||||
activity_df["Fuzzy Client Name"] = activity_df["Client Name"].apply(lambda x: fuzzy.get_best_match(target = x, choices = unique_new_clients, threshold = 0.5, partial = False))
|
||||
no_context_printer("Fuzzy Departments.")
|
||||
unique_new_departments = list(departments_by_name.keys())
|
||||
activity_df["Fuzzy Department"] = activity_df["Department"].apply(lambda x: fuzzy.get_best_match(target = x, choices = unique_new_departments, threshold = 0.5, partial = False))
|
||||
no_context_printer("Fuzzy Tasks.")
|
||||
unique_new_processes = list(processes_by_name.keys())
|
||||
activity_df["Fuzzy Task"] = activity_df["Task"].apply(lambda x: fuzzy.get_best_match(target = x, choices = unique_new_processes, threshold = 0.5, partial = False))
|
||||
|
||||
# Add the columns to the dataframe via fuzzy matching:
|
||||
no_context_printer("Adding user id to Excel.")
|
||||
activity_df["fuzzy_user_id"] = activity_df["Fuzzy Username"].apply(lambda x: users_by_pseudonym.get(x, {}).get("user_id", None))
|
||||
no_context_printer("Adding department id to Excel.")
|
||||
activity_df["fuzzy_department_id"] = activity_df["Fuzzy Department"].apply(lambda x: departments_by_name.get(x, {}).get("department_id", None))
|
||||
no_context_printer("Adding process id to Excel.")
|
||||
activity_df["fuzzy_process_id"] = activity_df["Fuzzy Task"].apply(lambda x: processes_by_name.get(x, {}).get("process_id", None))
|
||||
no_context_printer("Adding client id to Excel.")
|
||||
activity_df["fuzzy_client_id"] = activity_df["Fuzzy Client Name"].apply(lambda x: clients_by_name.get(x, {}).get("account_id", None))
|
||||
|
||||
# Save the file:
|
||||
print(activity_df[:10].to_string())
|
||||
print("...")
|
||||
print(activity_df[-10:].to_string())
|
||||
print(len(activity_df))
|
||||
activity_df.to_csv(r"/home/developer/Downloads/TaskManager - Data Matched - 20250203.csv", index = False)
|
||||
activity_df.to_csv(r"/home/developer/Downloads/TaskManager - Data Matched - 20250204 - Fuzzy 2.csv", index = False)
|
||||
|
||||
|
||||
# *****************************************************************************************************************
|
||||
|
||||
Reference in New Issue
Block a user