Black Lives Matter. Please consider donating to Black Girls Code today.

Hot Reload - Watch Excel File for Changes

I have created a Dash App with callbacks that gets its data from an Excel File. I want it to be the case that every time the Excel file is updated (eg, every time it is saved), I trigger a hot reload in Dash. I assume then Dash would read in the updated Excel file.

How can I get my Dash App to “watch” this Excel file for changes? I would prefer to do it without using DCC Interval because I want the app to update as soon as a change is made to the Excel file.

What you’re asking for is for the server to push an update to the client, in vanilla Dash this doesn’t exist. There may be some third party libraries that support it, e.g. but I have never used them.

However on one of my internal apps (and therefore very low latency between client and server) I use dcc.Interval set to run 5 times a second (but it doesn’t even have to be that fast, once a second is probably fine). You can keep track of if the file has updated by checking the mtime and keeping that in dcc.Store, if there isn’t an update you simply return dash.no_update. This really does appear at the front end like the page is updates as soon as the file has updated.

1 Like

Hi. I am looking for something similar, do you mind sharing the snippet? Thank you!