0

I want to run a job every day at 9:55 AM to load a data frame into an Excel sheet. I was able to figure out the below code that apparently does that. However, when I run the code, it's sort of perennially stuck in execution mode without any results. I basically do not want to open Pycharm every day to run this code. What do I need to add to run the job every day without me having to do anything at all?

def job():
    df=pd.DataFrame(np.random.randn(25).reshape(5, 5), index=[1, 2, 3, 4, 5], columns=['a', 'b', 'c', 'd', 'e'])
    writer=pd.ExcelWriter('test.xlsx')
    df.to_excel(writer,'Sheet1')
    writer.save()


schedule.every().day.at("09:55").do(job)

while True:
schedule.run_pending()
time.sleep(1)
Lax Mandis
  • 131
  • 4
  • 14

2 Answers2

1

For scheduling tasks, you better use software which was designed to do that. In nix environment it could be Cron, for example. For Win -- probably TaskScheduler. Anyway, you probably would like to take this approach: https://stackoverflow.com/a/2725908/2822774

Alex Bender
  • 846
  • 13
  • 26
0

i had a simmilar problem - u can see my py_scheduler library for it https://github.com/kl09/py_scheduler This is better to controll schduler job in your app, to make a special microservice for it, neither to use a cron

kl09
  • 31
  • 2