Created
December 31, 2018 00:08
-
-
Save adamfortuno/cc44242616e15f137f1ee35be109eb0f to your computer and use it in GitHub Desktop.
Map Active Directory User to Employee
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from fuzzywuzzy import fuzz | |
import pandas as pd | |
path_employee_list = "C:/Users/adam.fortuno/temp/employee_names.txt" | |
path_ad_users_list = "C:/Users/adam.fortuno/temp/ad-user-names.txt" | |
path_employee_to_aduser_mapping = "C:/Users/adam.fortuno/temp/mapping.csv" | |
employee_mapping = [] | |
with open(path_employee_list, "r") as employee: | |
for employee_name in employee: | |
employee_ad_user = { | |
"employee_name" : employee_name.strip(), "score" : 0, "username" : "" | |
} | |
print("Processing '%s'..." %(employee_ad_user['employee_name'])) | |
with open(path_ad_users_list, "r") as ad_user: | |
for ad_user_name in ad_user: | |
score = fuzz.token_sort_ratio(employee_name, ad_user_name.strip()) | |
if score > employee_ad_user['score']: | |
employee_ad_user['score'] = score | |
employee_ad_user['username'] = ad_user_name.strip() | |
employee_mapping.append(employee_ad_user) | |
df = pd.DataFrame(employee_mapping) | |
df.to_csv(path_employee_to_aduser_mapping, index=False) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment