Started and almost completed Mizuno Script
This commit is contained in:
@ -312,3 +312,7 @@ BDR team is launching their own academy/cert program. It's an internal program a
|
||||
They will be the QA tester in May
|
||||
|
||||
DONE: Send Katlin and Erin examples of customized login pages, forms, learning paths/dashboards, etc.
|
||||
|
||||
## 04/04/2023
|
||||
|
||||
TODO: Reach out to Katlin regarding admin/embedded.
|
||||
|
||||
@ -5,6 +5,7 @@ import Apikeys
|
||||
apiKey = Apikeys.walmartprod
|
||||
course_dict = {}
|
||||
|
||||
|
||||
def get_course():
|
||||
count = 0
|
||||
courses = []
|
||||
@ -22,11 +23,11 @@ def get_course():
|
||||
uuid = response["id"]
|
||||
name = response["attributes"]["name"]
|
||||
course_dict = {
|
||||
"id": uuid,
|
||||
"name": name,
|
||||
"status": status,
|
||||
"url": f"https://walmart.northpass.com/app/courses/{uuid}"
|
||||
}
|
||||
"id": uuid,
|
||||
"name": name,
|
||||
"status": status,
|
||||
"url": f"https://walmart.northpass.com/app/courses/{uuid}",
|
||||
}
|
||||
|
||||
# FIX: Up until here, each course gets read to the terminal.
|
||||
# FIX: After this, something is being overwritten.
|
||||
@ -37,6 +38,7 @@ def get_course():
|
||||
if "next" not in nextlink:
|
||||
break
|
||||
|
||||
|
||||
def get_cat_name(cat_id, course_dict, courses):
|
||||
headers = {"accept": "application/json", "X-Api-Key": apiKey}
|
||||
cats = []
|
||||
@ -61,7 +63,6 @@ def get_cat_name(cat_id, course_dict, courses):
|
||||
cats.append(cat_name)
|
||||
course_dict.update({"categories": cats})
|
||||
|
||||
|
||||
try:
|
||||
courses.append(course_dict)
|
||||
except TypeError as e:
|
||||
@ -74,5 +75,6 @@ def write_to_csv(courses):
|
||||
df = pd.DataFrame.from_dict(courses)
|
||||
df.to_csv("/Users/normrasmussen/Downloads/walmart_courses.csv")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
get_course()
|
||||
|
||||
58
Scripts/Mizuno/add-pgaids.py
Normal file
58
Scripts/Mizuno/add-pgaids.py
Normal file
@ -0,0 +1,58 @@
|
||||
import requests
|
||||
import pandas as pd
|
||||
from pathlib import Path
|
||||
import os
|
||||
|
||||
basefile = "/Users/normrasmussen/Downloads/mizuno-march-completions.csv"
|
||||
api_key = "stXNF84HWL8aCGeRjHEo2rJ1U"
|
||||
uuid_url = "https://api.northpass.com/v2/people?filter[email][eq]="
|
||||
prop_url = "https://api.northpass.com/v2/properties/people/"
|
||||
headers = {
|
||||
"accept": "*/*",
|
||||
"x-api-key": api_key,
|
||||
"content-type": "application/json",
|
||||
}
|
||||
drop_rows = []
|
||||
|
||||
def load_file(basefile):
|
||||
try:
|
||||
if os.path.isfile(basefile):
|
||||
basefile = Path(basefile)
|
||||
print(f"File found! Importing {basefile}")
|
||||
completions = pd.read_csv(basefile)
|
||||
for email in completions.itertuples():
|
||||
row_num = email[0]
|
||||
email = email[3]
|
||||
print(email)
|
||||
url = uuid_url + f"{email}"
|
||||
response = requests.get(url, headers=headers)
|
||||
if response.status_code == 200:
|
||||
print("Fetching person found!")
|
||||
response = response.json()
|
||||
uuid = response["data"][0]["id"]
|
||||
url2 = prop_url + f"{uuid}"
|
||||
response = requests.get(url2, headers=headers)
|
||||
data = response.json()
|
||||
pgaid = data["data"]["attributes"]["properties"]["account_number"]
|
||||
write_to_csv(pgaid, row_num, completions)
|
||||
except KeyError as e:
|
||||
print(e)
|
||||
finally:
|
||||
pass
|
||||
|
||||
def write_to_csv(pgaid, row_num, completions):
|
||||
print(pgaid)
|
||||
try:
|
||||
completions.loc[completions.index[row_num], "PGA ID"] = pgaid
|
||||
except (TypeError, KeyError) as e:
|
||||
print(e)
|
||||
finally:
|
||||
pass
|
||||
#completions.drop(completions["PGA ID"] == "0")
|
||||
print("the end?")
|
||||
print(completions)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
load_file(basefile)
|
||||
|
||||
Reference in New Issue
Block a user