Walmart Notes, Skuid script, etc
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
import requests
|
||||
|
||||
apiKey = "SlpQlju219WnWogn94dQUT6Yt"
|
||||
# apiKey = "SlpQlju219WnWogn94dQUT6Yt"
|
||||
apiKey = "VNDXh8K4tLYJ-Nvp78bo6w"
|
||||
url = "https://api.northpass.com/v1/media"
|
||||
# function = sys.argv[1]
|
||||
|
||||
@ -25,8 +26,9 @@ def putTest(apiKey, url):
|
||||
def getTest(apiKey, url):
|
||||
headers = {"accept": "application/json", "X-Api-Key": apiKey}
|
||||
response = requests.get(url, headers=headers)
|
||||
print(response.text)
|
||||
|
||||
# print(response.text)
|
||||
jsonResponse = response.json()
|
||||
# print(jsonResponse["data"][1]["attributes"])
|
||||
|
||||
def postTest(apiKey, url):
|
||||
headers = {
|
||||
|
||||
24
Scripts/API_Tests/medialib_csv.py
Normal file
24
Scripts/API_Tests/medialib_csv.py
Normal file
@ -0,0 +1,24 @@
|
||||
import requests
|
||||
import pandas as pd
|
||||
|
||||
apiKey = "VNDXh8K4tLYJ-Nvp78bo6w"
|
||||
url = "https://api.northpass.com/v1/media"
|
||||
|
||||
|
||||
def getMedia(apiKey, url):
|
||||
headers = {"accept": "application/json", "X-Api-Key": apiKey}
|
||||
response = requests.get(url, headers=headers)
|
||||
json = response.json()
|
||||
print(json)
|
||||
toCsv(json)
|
||||
|
||||
|
||||
def toCsv(json):
|
||||
js = pd.json_normalize(json, "links", "data", ["type", "attributes", ["asset_type"]])
|
||||
# js = pd.read_json(json, orient="index")
|
||||
print(js)
|
||||
js.to_csv("/Users/normrasmussen/Documents/Northpass/Scripts/API_Tests/spsmedia.csv")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
getMedia(apiKey, url)
|
||||
2
Scripts/API_Tests/spsmedia.csv
Normal file
2
Scripts/API_Tests/spsmedia.csv
Normal file
File diff suppressed because one or more lines are too long
@ -2,7 +2,7 @@ from collections import Counter
|
||||
import pandas as pd
|
||||
|
||||
basecsv = "/Users/normrasmussen/Documents/Northpass/Scripts/Skuid_LPs/Skuid_MCA125.csv"
|
||||
lpcsv = "/Users/normrasmussen/Documents/Northpass/Scripts/Skuid_LPs/skuidlps2.csv"
|
||||
lpcsv = "/Users/normrasmussen/Documents/Northpass/Scripts/Skuid_LPs/skuidlps.csv"
|
||||
|
||||
"""
|
||||
Example multivalue dictionary
|
||||
@ -29,28 +29,50 @@ How to create this by automation?
|
||||
"""
|
||||
|
||||
|
||||
def lpLevels(lpcsv):
|
||||
def lpLevels(basecsv, lpcsv):
|
||||
levels = pd.read_csv(
|
||||
lpcsv,
|
||||
index_col=None,
|
||||
header=None,
|
||||
index_col=1,
|
||||
)
|
||||
newDf = levels.groupby("Learning Path")
|
||||
learningpaths = newDf.apply(lambda x: x["Course Name"].unique())
|
||||
# learningpaths = newDf2.apply(pd.Series)
|
||||
# learningpaths.rename_axis(index=0)
|
||||
mainFunc(basecsv, learningpaths)
|
||||
# print(levels.Level.unique()) # Print only unique values from the Level column
|
||||
|
||||
|
||||
def mainFunc(basecsv):
|
||||
def mainFunc(basecsv, learningpaths):
|
||||
# Part 1
|
||||
readData = pd.read_csv(
|
||||
basecsv,
|
||||
)
|
||||
# lp01 = readData[readData["Course Name"] ==
|
||||
# print(lp01)
|
||||
# people = lp01.groupby(["Email", "Learner Full Name"])["Course Name"].nunique()
|
||||
# print(people)
|
||||
# readData.drop_duplicates(subset="Course Name", keep="first")
|
||||
lvl1 = readData.loc["Course Name"].any()
|
||||
if lvl1.str.contains('Level 1'):
|
||||
emailGroups = readData.groupby(["Email", "Learner Full Name"])["Course Name"].nunique()
|
||||
print(emailGroups)
|
||||
group = readData.groupby("Learner Full Name")
|
||||
df2 = group.apply(lambda x: x["Course Name"].unique())
|
||||
df2 = df2.apply(pd.Series, dtype="string")
|
||||
# print(df2)
|
||||
# This prints a dataframe with the learner's name as the index column and the courses as adjacent columns
|
||||
|
||||
# Part 2
|
||||
# learningpaths.set_index(0)
|
||||
# print(courses)
|
||||
lp_dict = learningpaths.to_dict()
|
||||
courses = lp_dict.values()
|
||||
print(courses)
|
||||
# crs = courses
|
||||
# print(crs)
|
||||
|
||||
# Part 3
|
||||
# for course in courses:
|
||||
# print(df2.isin(course))
|
||||
|
||||
# df3 = df2.columns
|
||||
# print(df3)
|
||||
# for name in df3.items():
|
||||
# print(f"name: {name}")
|
||||
|
||||
# emailGroups = readData.groupby(["Email", "Learner Full Name"])["Course Name"].nunique()
|
||||
# print(emailGroups)
|
||||
# emailGroups = people.to_csv(
|
||||
# "/Users/normrasmussen/Documents/Northpass/Scripts/Skuid_LPs/outtest2.csv"
|
||||
# )
|
||||
@ -70,5 +92,5 @@ def mainFunc(basecsv):
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
mainFunc(basecsv)
|
||||
# lpLevels(lpcsv)
|
||||
# mainFunc(basecsv)
|
||||
lpLevels(basecsv, lpcsv)
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
Level,LP,Course Name
|
||||
Level,Learning Path,Course Name
|
||||
Level 1,01: Skuid Ethos - Level 1,Congratulations! You've been accepted to Skuid Skool
|
||||
Level 1,01: Skuid Ethos - Level 1,Create Your Own Dev Org Environment/Install Skuid - Level 1
|
||||
Level 1,01: Skuid Ethos - Level 1,Skuid Resources
|
||||
|
||||
|
Reference in New Issue
Block a user