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

Programmatic export as HTML #765

Open
eliasecchig opened this issue Jun 13, 2023 · 1 comment
Open

Programmatic export as HTML #765

eliasecchig opened this issue Jun 13, 2023 · 1 comment

Comments

@eliasecchig
Copy link

Hi all,

I am trying to export programmatically a view as HTML file. Do you know if this is already possible?
My objective is to enable tools without an UI (like an orchestrator) to generate the report and save the HTML File.

Thanks!

@aschonfeld
Copy link
Collaborator

Currently D-Tale supports HTML exports of the current grid (includes the majority of the grid functionality minus anything that requires a call to the server). You can access that functionality by opening the main menu clicking "Export" and then pressing the "HTML" button.

Now this is the part that I'm not 100% sure how it will work programmatically, but essentially if you have a running D-Tale process you can hit the endpoint to generate the file:

import requests
import pandas as pd
import time


ts = time.mktime(pd.Timestamp('now').timetuple())
# 'export_rows' is the number of rows in the dataframe, but you can specify any number
# one thing to be aware of is if your dataframe is large then this file will be really huge and may not work
requests.get(f"http://[hostname]:[dtale port]//dtale/data/1?export=true&export_rows=100&_id={ts}")

Not totally sure what will be returned by the requests.get since it serves up an HTML file. So you'll have to do some work around how to save it down to a specific location. But I'd assume it just returning the bytes of an HTML file which you could pass to a file object and specify the location.

Good luck

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

No branches or pull requests

2 participants