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()
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter