Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[watch]: Add a way to automatically reload a data source based on time or other event. #683

Closed
frosencrantz opened this issue Sep 5, 2020 · 6 comments

Comments

@frosencrantz
Copy link
Contributor

The Unix watch command periodically runs the same command so you can see the results over time.
It would be useful if Visidata could automatically reload the same data source after a specified time.

It would also be useful if Visidata could run a command as a data source. Currently it can only open files or URLs.

@geekscrapy
Copy link
Contributor

I'd love this also - maybe a watcher thread that does the check and issues a reload if required?

@saulpw
Copy link
Owner

saulpw commented Sep 13, 2020

This is a good idea, @frosencrantz. The original prototype of VisiData (called "tpmenu") had this feature, to reload the page every N seconds. It also had something like addcol-derivative which created a column with a derivative of the current numeric column (so you could calculate rate from totals, for instance). It was really useful for monitoring network statistics.

Kondo'ed per wishlist policy. (A Workflow Optimist subscriber on Patreon can keep it open and in our awareness.)

@saulpw saulpw closed this as completed Sep 13, 2020
@frosencrantz
Copy link
Contributor Author

I like the idea of the addcol-derivative. I think that would be great. The other thing that might be useful is a way to auto join on each reload, so that multiple input sources can be combined.

I do remember you saying something about the tpmenu in one of your interviews, though not by name.

Thanks, @saulpw. I will wait until I can officially support the wishlist or a real sponsor does.

@dufferzafar
Copy link
Contributor

@saulpw Was this ever picked up again? What's the current state of "reloading the data source" in visidata?

My usecase is to "watch" a CSV file that gets updated on the server ever 5-10 seconds. So by running something like vd http://urlto.csv/ I can keep visidata open and it refreshes the data every 10 seconds.

How hard would it be to implement this as a separate sheet AutoRefreshCsvSheet() ?

Having custom columns working with a reloading sheet would be good to have as well.

@saulpw
Copy link
Owner

saulpw commented May 1, 2022

Try this in your .visidatarc:

BaseSheet.addCommand('', 'watch-sheet', 'sheet.reload_every(int(input("reload interval (sec): ", value=1)))')

@BaseSheet.api
@asyncthread
def reload_every(sheet, seconds):
    import time
    while True:
        sheet.reload()
        time.sleep(seconds)

I also added this to vdplus.

saulpw added a commit to visidata/vdplus that referenced this issue May 1, 2022
@frosencrantz
Copy link
Contributor Author

Thanks, @saulpw! Very happy to see this new feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants