awacke1 commited on
Commit
831d7c3
ยท
1 Parent(s): 80678bd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -0
app.py CHANGED
@@ -2,6 +2,14 @@ import streamlit as st
2
  import pandas as pd
3
  import plotly.express as px
4
  import plotly.graph_objects as go
 
 
 
 
 
 
 
 
5
 
6
  # Function to plot the map
7
  def plot_map(data):
@@ -37,3 +45,8 @@ if display_map_button:
37
  st.plotly_chart(plot_map(data))
38
  else:
39
  st.write("Please upload a CSV file to proceed. ๐Ÿ“‘")
 
 
 
 
 
 
2
  import pandas as pd
3
  import plotly.express as px
4
  import plotly.graph_objects as go
5
+ import base64
6
+
7
+ # Function to create a download link
8
+ def create_download_link(file_path, link_title):
9
+ with open(file_path, 'rb') as file:
10
+ csv_data = file.read()
11
+ b64 = base64.b64encode(csv_data).decode()
12
+ return f'<a href="data:file/csv;base64,{b64}" download="{link_title}.csv">{link_title}</a>'
13
 
14
  # Function to plot the map
15
  def plot_map(data):
 
45
  st.plotly_chart(plot_map(data))
46
  else:
47
  st.write("Please upload a CSV file to proceed. ๐Ÿ“‘")
48
+
49
+ # Download link for the CSV file
50
+ csv_file_path = 'top_corporation_per_state.csv'
51
+ download_link = create_download_link(csv_file_path, "Top Corporations by State")
52
+ st.markdown(download_link, unsafe_allow_html=True)