Fixed walmart screenshot script. Added some notes. Created recast's script.

This commit is contained in:
Norm Rasmussen
2023-04-04 16:55:32 -04:00
parent 9ef9e63297
commit ecdf46fd33
10 changed files with 158 additions and 30 deletions

BIN
Scripts/Mizuno/.DS_Store vendored Normal file

Binary file not shown.

View File

@ -1,10 +1,11 @@
import requests
import pandas as pd
from pathlib import Path
import Apikeys
import os
basefile = "/Users/normrasmussen/Downloads/mizuno-march-completions.csv"
api_key = "stXNF84HWL8aCGeRjHEo2rJ1U"
basefile = "/Users/normrasmussen/Downloads/Recast-learners.csv"
api_key = Apikeys.recast
uuid_url = "https://api.northpass.com/v2/people?filter[email][eq]="
prop_url = "https://api.northpass.com/v2/properties/people/"
headers = {
@ -12,45 +13,45 @@ headers = {
"x-api-key": api_key,
"content-type": "application/json",
}
drop_rows = []
def load_file(basefile):
dict_list = []
row_dict = {}
basefile = Path(basefile)
completions = pd.read_csv(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]
row_dict = {"row_num":row_num}
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)
row_dict["pgaid"] = pgaid
dict_list.append(row_dict)
print("No errors! Passing along the dictionary!")
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?")
for info in dict_list:
row = info['row_num']
pid = info['pgaid']
completions.loc[completions.index[row], "PGA ID"] = pid
completions = completions[completions["PGA ID"] != "0"]
#completions = completions.iloc[:, 0:]
print(completions)
completions.to_csv(
"/Users/normrasmussen/Downloads/MizunoCompletions_with_PGAIDs.csv",
index=False
)
if __name__ == "__main__":