Export to excel with current month name
Thu Mar 11 2021 15:29:12 GMT+0000 (Coordinated Universal Time)
Saved by
@stephenb30
#python
import datetime as dt
import os
#Folder Creation
Directory = 'C:/Users/Username/Desktop'
now = dt.datetime.now()
CompletedFor = now + relativedelta(months=+1)
CompletedForNumber = CompletedFor.month
CompletedForWord = CompletedFor.strftime('%B')
FollowingMonth = "{}. {}".format(CompletedForNumber, CompletedForWord)
os.makedirs(Directory + FollowingMonth)
###Creating Date for File Name
Today = dt.datetime.now()
ContactDate = Today.replace(day=1) + relativedelta(months=+2) - relativedelta(days=1)
ContactDate = ContactDate.strftime('%d%B')
#Exporting to one excel file with two sheets with end of following month in name
SaveLocation = Directory + FollowingMonth
os.chdir(SaveLocation)
writer = pd.ExcelWriter('ThisIsTheFIle' + ContactDate + '.xlsx',engine='xlsxwriter')
Sheet1_df.to_excel(writer, sheet_name='Sheet1', index=False)
Sheet2_df.to_excel(writer, sheet_name='Sheet2', index=False)
writer.save()
content_copyCOPY
Comments