Updated all the notes so my script would pull them automatically without any errors. The script is almost done, but I can't seem to get it to merge all the dictionaries! Those were most of the changes for this commit.

This commit is contained in:
Norm Rasmussen
2023-07-26 17:42:52 -04:00
parent d2378e4f44
commit 2320513c9f
52 changed files with 633 additions and 689 deletions

View File

@ -1,26 +1,36 @@
from pathlib import Path
import requests
import pandas as pd
import itertools
ndir = Path("/Users/normrasmussen/Documents/Work/CustomerNotes/")
def get_files():
list_of_lists = []
merge = pd.DataFrame()
merge3 = pd.DataFrame()
merged = pd.DataFrame()
files = list(ndir.glob("**/*.md"))
for company in files:
# This Section gets the Company name for the payload.
company = str(company)
company_file = company.split("/")[-1]
company_name = company_file[:-3]
if company_name == "Bolt":
get_data(company_file, company_name)
# if company_name == "Bolt":
list_of_dicts = get_data(company_file, company_name)
dic = pd.DataFrame.from_records(list_of_dicts)
dict_copy = dic.copy()
merge = pd.concat([dict_copy, merge], ignore_index=True)
print(merge)
def get_data(company_file, company_name):
sdir = "/Users/normrasmussen/Documents/Work/CustomerNotes/"
notes = []
line_num_array = []
text_array = []
list_of_dicts = []
pay_dict = {"company_name": company_name}
company_path = Path(
f"/Users/normrasmussen/Documents/Work/CustomerNotes/{company_file}"
)
@ -52,30 +62,43 @@ def get_data(company_file, company_name):
# Now we are cleaning it up.
# Removing the hashes from the dates and titles.
for note in notes:
date = note[0][2:]
if note[2].startswith("### "):
note_title = note.pop(2)[3:]
date = note[0][3:]
copy = " ".join(note[1:])
pay_dict["date"] = date
pay_dict["copy"] = copy
pay_dict["type"] = "Meeting"
if note[2].startswith("### "):
note_title = note.pop(2)[4:]
pay_dict["title"] = note_title
else:
pay_dict["title"] = f"Meeting Notes from {date}"
list_of_dicts.append(pay_dict.copy())
# print(list_of_dicts)
return list_of_dicts
def add_to_payload(date, note_title, copy, company_name):
def add_to_payload(pay_dict):
payload = {
"records": [
{
"Author": "nrasmussen@gainsight.com",
"ContextName": company_name,
"ContextName": pay_dict["company_name"],
"TypeName": "Meeting",
"ExternalId": "WHAT IS THIS?",
"Subject": note_title,
"Notes": copy,
"ActivityDate": date,
"Subject": pay_dict["title"],
"Notes": pay_dict["copy"],
"ActivityDate": pay_dict["date"],
"companyName": "AAR Corp Hardware Abscoa Division",
"internalAttendees": ["Norm Rasmussen"],
"externalAttendees": [""],
},
]
}
send_to_gs(payload)
print(payload)
"""
# send_to_gs(payload)
def send_to_gs(payload):
@ -86,7 +109,7 @@ def send_to_gs(payload):
"Accesskey": APIKEY,
}
response = requests.post(url=url, headers=headers, json=payload)
"""
if __name__ == "__main__":
get_files()