I'm fairly new at Python in general, but I'm trying to create a small background application that will read an excel file and send me an e-mail every day on some condition. I was wondering what is the best way to go about this? Should I just use some sort of loop where it does the action every so many seconds, and then execute the script from the command line? Is there a way to make it into a standalone background app? Thanks for your answers.
Asked
Active
Viewed 2,215 times
1
-
which operating system are you using ? – sachin saxena Jun 18 '15 at 06:33
-
2Set up your script to run repeatedly using the Windows Task Scheduler. It can run any kind of program, including things like `python.exe C:\path\to\the\script.py`. – poke Jun 18 '15 at 06:34
-
You have to use startup tasks to run the python script upon startup so you don't forget to start it upon system restarts. – Alex Huszagh Jun 18 '15 at 06:34
-
You could use 'threading.Timer' in combination with from 'datetime import datetime' For more information see - http://stackoverflow.com/questions/11523918/python-start-a-function-at-given-time – user3636636 Jun 18 '15 at 06:40
-
Yes I'm using Windows, and I considered the task scheduler, but then I thought, what if others wanted to download this script? So I'm trying to figure out how to make it into a standalone app. @Alexander - thanks for the tip! I wouldn't have thought of that issue. – Phil D Jun 19 '15 at 19:17
-
@user3636636 That's a good idea, how does it compare to the apscheduler library? – Phil D Jun 19 '15 at 19:19
1 Answers
1
Take a look at http://apscheduler.readthedocs.org/en/3.0/
Here is an example from there site:
from datetime import datetime
import os
from apscheduler.schedulers.blocking import BlockingScheduler
def tick():
print('Tick! The time is: %s' % datetime.now())
if __name__ == '__main__':
scheduler = BlockingScheduler()
scheduler.add_executor('processpool')
scheduler.add_job(tick, 'interval', seconds=3)
print('Press Ctrl+{0} to exit'.format('Break' if os.name == 'nt' else 'C'))
try:
scheduler.start()
except (KeyboardInterrupt, SystemExit):
pass
Edit: I assumed this was the main point of your question. Re -reading however, are you wanting to know the whole process? -
How to read from excel file
How to automate an email
How to time/ schedule the function call
How to package as a desktop app
That is a loaded question. Let me know if you want me to elaborate on those points too

user3636636
- 2,409
- 2
- 16
- 31
-
Thanks for the answer! I actually looked into this library before, I just wasn't sure how to implement it. Well, I figured out the first two points (email and excel) but my question was more oriented towards the last two (schedule and package). Could you please elaborate on the last point? – Phil D Jun 19 '15 at 19:15