John
John

Reputation: 1

Printing a CSV table on a webpage using flask

So I tried using pandas to create the dataframe and finally convert it to an html file and put the data in dataset.html. So I left the dataset.html file empty. But when I run this, the '/dataset' page is empty. How do I fix this?

from flask import Flask, render_template
import pandas as pd

app = Flask(__name__)

@app.route('/')    
def home_page():    
    return render_template("home.html")

@app.route('/dataset')    
def another_page():    
    table = pd.DataFrame.from_csv("Soccer.csv")
    return render_template("dataset.html", data=table.to_html)

if __name__ == '__main__':    
    app.run(debug=True, use_reloader=True)

Upvotes: 0

Views: 5030

Answers (1)

doru
doru

Reputation: 9110

You should have data=table.to_html() to_html() is a function

Upvotes: 1

Related Questions