Swift Templates, Talkspace, Notes
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
import requests
|
||||
|
||||
apiKey = "HIDDEN_KEY"
|
||||
|
||||
apiKey = "84GO7zb7a990UJrnFJqiYcd0m"
|
||||
# Skuid's API
|
||||
|
||||
def getallUuid(apiKey):
|
||||
x = 0
|
||||
|
||||
@ -7,60 +7,63 @@ import csv
|
||||
import pandas as pd
|
||||
|
||||
rootdir = "/Users/normrasmussen/Documents/Resources/Walmart/"
|
||||
downloadir = "/Users/normrasmussen/Google Drive/My Drive/Shared with Clients/Walmart/"
|
||||
basefile = "WalmartTemplate.xlsx"
|
||||
downloadir = "/Users/normrasmussen/Google Drive/My Drive/Shared with Clients/Walmart_Looker/"
|
||||
basefile = "Walmart_Weekly_Base.xlsx"
|
||||
|
||||
|
||||
def copytemplate(rootdir, basefile):
|
||||
today = date.today()
|
||||
today = today.strftime("%m.%d.%Y")
|
||||
template = rootdir+basefile
|
||||
template = rootdir + basefile
|
||||
todayFile = f"Walmart-{today}.xlsx"
|
||||
if os.path.exists(rootdir):
|
||||
shutil.copy2(template, rootdir+todayFile)
|
||||
#dirfiles = os.listdir(rootdir)
|
||||
#print(dirfiles)
|
||||
currentDash = rootdir+f"Walmart-{today}.xlsx"
|
||||
print(currentDash)
|
||||
shutil.copy2(template, rootdir + todayFile)
|
||||
# dirfiles = os.listdir(rootdir)
|
||||
# print(dirfiles)
|
||||
currentDash = rootdir + f"Walmart-{today}.xlsx"
|
||||
# print(currentDash)
|
||||
findlatestExport(currentDash)
|
||||
|
||||
|
||||
def findlatestExport(currentDash):
|
||||
listfiles = glob.glob(downloadir + '*.csv')
|
||||
listfiles = glob.glob(downloadir + "*.csv")
|
||||
latestdownload = max(listfiles, key=os.path.getctime)
|
||||
print(latestdownload)
|
||||
# print(latestdownload)
|
||||
copytoDash(latestdownload, currentDash)
|
||||
|
||||
|
||||
def copytoDash(latestdownload, currentDash):
|
||||
readExport = pd.read_csv(
|
||||
latestdownload,
|
||||
index_col=False,
|
||||
header=0,
|
||||
low_memory=False,
|
||||
dtype={
|
||||
'Progress':object
|
||||
}
|
||||
)
|
||||
latestdownload,
|
||||
index_col=False,
|
||||
header=0,
|
||||
low_memory=False,
|
||||
# dtype={"Progress": float},
|
||||
)
|
||||
print(readExport)
|
||||
readExport.drop(
|
||||
readExport.filter(
|
||||
regex="Unname"
|
||||
),axis=1,
|
||||
inplace=True)
|
||||
readExport['Progress'] = readExport['Progress'].str[:-1].apply(pd.to_numeric)
|
||||
# readExport['Progress'].apply(pd.to_numeric, errors='ignore')
|
||||
print(readExport['Progress'])
|
||||
readExport.drop(readExport.filter(regex="Unname"), axis=1, inplace=True)
|
||||
copiedData = readExport.copy()
|
||||
bringtoExcel(latestdownload, currentDash, copiedData)
|
||||
|
||||
|
||||
def bringtoExcel(latestdownload, currentDash, copiedData):
|
||||
with pd.ExcelWriter(
|
||||
currentDash,
|
||||
mode="a",
|
||||
engine="openpyxl",
|
||||
if_sheet_exists="overlay",
|
||||
currentDash,
|
||||
mode="a",
|
||||
engine="openpyxl",
|
||||
if_sheet_exists="overlay",
|
||||
# engine_kwargs={'options': {'strings_to_numbers': True}}
|
||||
) as writer:
|
||||
copiedData.to_excel(
|
||||
writer,
|
||||
engine="xlsxwriter",
|
||||
sheet_name="Data",
|
||||
index=False,
|
||||
)
|
||||
writer,
|
||||
engine="xlsxwriter",
|
||||
sheet_name="Data",
|
||||
index=False,
|
||||
)
|
||||
|
||||
|
||||
def cleanitUp(currentDash):
|
||||
cleanExcel = pd.read_excel(currentDash, sheet_name="Data", index_col=None)
|
||||
@ -68,5 +71,6 @@ def cleanitUp(currentDash):
|
||||
cleanExcel.drop(columns="tmp", axis=1, inplace=True)
|
||||
print(cleanExcel)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
copytemplate(rootdir, basefile)
|
||||
|
||||
Reference in New Issue
Block a user