Generate static HTML report from CSV data file


#1

I am designing a Python module that reads a CSV data file and generates an HTML report showing statistics (mean, median, standard deviation, etc) numbers and distribution plots.

My input CSV data:
id,stage,height,weight,age,health
1,7,9,13,31,high
2,5,8,12,31,high
3,7,9,13,31,low
5,5,8,11,31,high

My output HTML report table:
Feature | Type | Mean | Standard Deviation | Plot-1 | Plot-2
id | Int | 50.5 | 21.3 | FDPS | FDPS
stage | Int | 30.2 | 27.4 | FDPS | FDPS
height | Decimal | 37.1 | 7.4 | FDPS | FDPS
weight | Decimal | 7.1 | 3.4 | FDPS | FDPS
age | Decimal | 7.1 | 3.4 | FDPS | FDPS
health | Categorical | N.A | N.A | FDPS | FDPS

FDPS: Fancy Dash/interactive Plot that the user can Save from the browser if possible.

My questions:

  1. Would Dash be the right tool to get this done?
  2. Can you share relevant code example?
  3. Is there a complete Dash documentation that describes the api?

Thank you!


#2

Trying to get @nedned attention.


#3

This sounds like a great use-case for Dash to me. Have you worked through the Dash Guide yet? While it’s not quite as comprehensive as it could perhaps be, it’s got most of the Dash API covered, and certainly enough to get stuck into project. If you have any more specific questions or run into any challenges, can certainly offer suggestions.


#4

Thanks @nedned, I’ve made some progress since. I’m not a web developer and don’t know much of JS which might be why I’m having trouble with Dash’s API documentation.
Can you explain how to make the HTML static? I need to be able to zip the resulting website (html, js, etc.) and email it to a friend who will unzip and, without anything but a browser, be able to see my table and plots.
I’m sorry if that’s too basic of a question but on my machine I need to be running Dash’s server locally in order to view the generated html.
Thanks again.


#5

Unfortunately that’s not possible with Dash. Dash is very much set up as a client-server paradigm, so you’ll need to be running your app on a server somewhere for it to be available to others. Broadly, the options you have are:

  1. Get yourself access to a server that you can run Dash on. There’s a bit of a learning curve here if you haven’t done much web dev before, but if you’re prepared to go through some tutorials, it’s quite feasible. Google something like “how to host a Flask app”. Heroku could be a good option simply because there are instructions on the Dash Guide and people have posted about this here.
  2. Run your app locally and use ngrok to tunnel your app through to a publicly accessible IP address. This is the simplest, but requires that your computer be on for your friend to use the app and doesn’t scale to more than 10 or so users before you probably need to go premium.
  3. Use a different tool other than Dash, one that assembles your app as a static page. Perhaps something like Jinja2 templates (without Flask) combined with a plotting tool that makes offline interactive charts. Either Plotly or Bokeh maybe. I’ve not had experience with this route so can’t give a more concrete recommendation.

There are surely more strategies, but they seem like the notable ones to me.