Skip to main content

Python script - pop-up reminder based on data from Excel



Completion date: December 17, 2018

Changes to the script (Dec 14 2018):

1. Used Date format to compare dates. 

2. Show message for update AR if the date is overdue and due today.

Changes to the script (Dec 17 2018):

1. Corrected the ws.max_row+1 to ws.max_row.

2. Changed to loop from bottom up (so the the newest records gets checked first)

=========== The script ===========
#! python3 -- Modified on Dec 17 2018
import openpyxl
import tkinter.messagebox
from datetime import date
import os

#Get the workbook, worksheet
file = "AR.xlsx"
wb = openpyxl.load_workbook(file)
ws = wb['Sheet1']

#Iterate through the rows of column "Next update on" = Column D = 4, from bottom up (the newest record to oldest)
for i in range(ws.max_row, 2, -1):
    next_update_datetime = ws.cell(row=i, column=4).value
    if (next_update_datetime is not None):
        #convert to date
        next_update_date = next_update_datetime.date()

    #Check if any AR is due or overdue for update
    if next_update_date <= date.today():
        result = tkinter.messagebox.askquestion("AR Progress Update Reminder", "You need to update AR today.  Would you like to open the workbook?", icon='question')
        if result == 'yes':
            os.startfile(file)
            break
        else:
            break
=========== End of script ===========


Completion date: December 7, 2018

It has been a while since my last invention stories.  Last week, I have created something using Python programming language.

My application is a simple script that checks if anything are due for update on the day.  I have configured it to run automatically on each Windows startup (I turn off my notebook every day after work).  It is to help my work on chasing the accounts receivables, as I realize I might forget to update since it is not a daily chore.  So, the program would check if I have anything due on a the day under “Next update on” column in the excel file, without me opening the excel file.  If there is something due for update on the day, I would get a dialog box (picture above) to open the excel file, if not, the dialog box will not pop up.

Here is the script below, it’s very simple but it works.

Remark: I created an .exe file from .py using pyinstaller, and then I put a shortcut of the .exe file in the startup folder (Win+R —> shell:startup).

Alternatively, you can create a scheduled task in  Windows (in system tools) for auto-running the script at a specific hour.

===================================
#! python3 -- Created on Dec 7 2018
import openpyxl
import tkinter.messagebox
from datetime import date
import os

#Get the workbook, worksheet
file = "AR.xlsx"
wb = openpyxl.load_workbook(file)
ws = wb['Sheet1']

#Iterate through the rows of column "Next update on" = Column D = 4
for i in range(2, ws.max_row+1):
   next_update_datetime = str(ws.cell(row=i, column=4).value)
   next_update_date = next_update_datetime[0:10]
   if next_update_date == str(date.today()):
       result = tkinter.messagebox.askquestion("AR Progress Update Reminder", "You need to update AR today.  Would you like to open the workbook?", icon='question')
       if result == 'yes':
           os.startfile(file)
           break
       else:
           break
===================================

Comments

Popular posts from this blog

Mahjong table frame

Purpose: To make a collapsible frame for a portable table.  Completion date: 2025-01-12 The main purpose of the frame: Provide raised step (~0.5cm height) for aligning the tiles in a straight line A place to put turned-over tiles along the frame Raised step design to prevent the tiles from falling off the table Portable table: 34” x 34” Mahjong mat: 31” x 31” Materials: Cardboard Adhesive wallpaper Double-sided tape 4 x L-shape brackets Paper Nano tape 8 x snap button bottom part Old ziploc bag Non-slip mat backing Steps Cut 8 strips of cardboard.  4 pieces: 1” x 34” 4 pieces: 0.75” x 34” Fit set of four strips (0.75”) on the table with the mat.  Mark and cut two ends 45 degrees.  Fit the strips around the mat snug with its inner edge against the mat's edge. To check if snug: push the frame strips and see if it moves the mat. If yes, good. If not, try to reduce the slack gap in between the frame and the mat rim (could swap the strips to find best fit).  Mark the...

Banbao LEGO: motorcycle

Completion date: April 14, 2020 My banbao LEGO is here! My first project is building motorcycle from manual. My reflection on this build - three gears linear cluster turns the gears in a way that the 1st and 3rd gears are in the same direction.  - the 3-gear cluster’s function is to displace the turning motion to happen in another place. In this case, the back wheels can’t be directly connected to the motor, that’s why the 3-gear cluster would help.  - there are two types of connectors that look similar but provide a bit different functions. They act as pivot. One is smooth-pivot, the other is a stuck-pivot (need more force to turn) My first encounter with Banbao: really happy.  - It is not as good as LEGO in the fitting - It is really cheap, I imagine this would cost around HK$1000 with LEGO. Now around 1/3 of the price - It seems there are more variety of parts than LEGO - LEGO has actual size illustration on page for axles. Banbao could provide ruler sticker as a...