From 48c35debc8e2cdeac8a76747971027be99195c31 Mon Sep 17 00:00:00 2001 From: Filip Izydorczyk Date: Mon, 21 Jun 2021 15:44:53 +0200 Subject: [PATCH] Added downloading selected file --- finance.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/finance.py b/finance.py index a9226e2..5c80b47 100755 --- a/finance.py +++ b/finance.py @@ -150,14 +150,15 @@ app.layout = html.Div( ] ) +# Callback for downloading file @app.callback( Output("download-data", "data"), - Input("btn_data", "n_clicks"), + [Input("btn_data", "n_clicks"), Input('table_selector', 'value')], prevent_initial_call=True, ) -def create_download_file(n_clicks): +def create_download_file(n_clicks, selected_table): global selected_stock_in_table_df - return dcc.send_data_frame(selected_stock_in_table_df.to_csv, "data.csv") + return dcc.send_data_frame(selected_stock_in_table_df.to_csv, "data-{table}.csv".format(table = selected_table)) # Callback for timeseries price @app.callback(Output('timeseries', 'figure'), [Input('stockselector', 'value')])