Finished/refactored the add-to-csv script for Talkspace to move faster and not make so many API calls. Added some notes for Datasnipper.
This commit is contained in:
@ -24,11 +24,12 @@ def load_file(basefile):
|
||||
if os.path.isfile(basefile):
|
||||
print(f"File found! Importing {basefile}")
|
||||
for email in completions.itertuples():
|
||||
row_num = email[1]
|
||||
row_num = email[0]
|
||||
row_dict = {"row_num": row_num}
|
||||
email = email[3]
|
||||
url = uuid_url + f"{email}"
|
||||
response = requests.get(url, headers=headers)
|
||||
print(response)
|
||||
if response.status_code == 200:
|
||||
response = response.json()
|
||||
uuid = response["data"][0]["id"]
|
||||
@ -38,6 +39,7 @@ def load_file(basefile):
|
||||
userid = data["data"]["attributes"]["properties"]["user_id"]
|
||||
row_dict["userid"] = userid
|
||||
dict_list.append(row_dict)
|
||||
print(dict_list)
|
||||
print("No errors! Passing along the dictionary!")
|
||||
except KeyError as e:
|
||||
print(f"{e} and the rest")
|
||||
|
||||
Reference in New Issue
Block a user