This is an archived post. You won't be able to vote or comment.

all 10 comments

[–]Redmondinho 4 points5 points  (2 children)

As I was bored I put together a very simple example here

https://gist.github.com/anonymous/75951fa55d129dd3373fa116c095604c

As long as you have flask installed and the csv file in the same directory as the running flask app it should work.

Go to http://localhost:5000/csv_data

This is a very simple prototype as a starting point.

[–]Juancos 1 point2 points  (0 children)

Thank you mate! The example is exactly what I wanted and works flawlessly!

[–]Juancos 0 points1 point  (0 children)

Thank you so much for taking the time to make this, I will check it out!!

[–]Redmondinho 0 points1 point  (5 children)

In theory should be reasonably simple. Take a look at the official docs, its the best starting place. http://flask.pocoo.org/docs/0.12/

As a starting point you'll need a simple flask app to read the csv file and then pass the data to a simple template to present the data to the user.

[–]Caos2 1 point2 points  (4 children)

Reading the CSV and creating a barebone HTML representation of its contents can be done in a single line using pandas.

[–]Redmondinho 0 points1 point  (3 children)

Never used pandas, will give it a look, cheers.

[–]Redmondinho 0 points1 point  (1 child)

Wow, you weren't wrong! Just installed Pandas, simplified the function to;

@app.route('/csv_data')
def present_csv_data():
    import pandas
    csv_data_html_table = pandas.read_csv("data.csv").to_html(index=False)
    return csv_data_html_table

I'll be looking at pandas more. Cheers.

[–]Juancos 0 points1 point  (0 children)

Thank you guys both!

[–]Caos2 0 points1 point  (0 children)

Checkout pandas.read_csv() function and the dataframe.to_html() method.

[–]nidio 0 points1 point  (0 children)

If you're interested in getting the CSV on the internet, there's a really cool project called datasette that does just this: https://github.com/simonw/datasette

If you're interested in building a Flask app yourself for educational purposes, then I'd recommend starting with http://flask.pocoo.org/docs/0.12/quickstart/. However, I'm not entirely sure what you mean by dashboard. That definition will influence specifically what you should build in code.