Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -140,7 +140,8 @@ def generate_streamlit_app_code(app_title, app_subtitle, side_panel_title, analy
|
|
| 140 |
analysis_functions_code = "\n ".join([PREDEFINED_ANALYSIS[task]['Code'].replace("\n", "\n ") for task in analysis_tasks])
|
| 141 |
# Here we ensure that calls to analysis functions are correctly indented within the main function
|
| 142 |
analysis_tasks_code = "\n".join([f" {PREDEFINED_ANALYSIS[task]['Function']}(df)" for task in analysis_tasks])
|
| 143 |
-
|
|
|
|
| 144 |
code = f"""import streamlit as st
|
| 145 |
import pandas as pd
|
| 146 |
import seaborn as sns
|
|
@@ -149,23 +150,22 @@ import plotly.express as px
|
|
| 149 |
{requirements}
|
| 150 |
|
| 151 |
def main():
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
st.sidebar.title("{side_panel_title}")
|
| 156 |
|
| 157 |
-
|
| 158 |
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
|
| 164 |
-
|
| 165 |
|
| 166 |
{analysis_functions_code}
|
| 167 |
-
|
| 168 |
-
|
| 169 |
{analysis_tasks_code}
|
| 170 |
|
| 171 |
if __name__ == "__main__":
|
|
|
|
| 140 |
analysis_functions_code = "\n ".join([PREDEFINED_ANALYSIS[task]['Code'].replace("\n", "\n ") for task in analysis_tasks])
|
| 141 |
# Here we ensure that calls to analysis functions are correctly indented within the main function
|
| 142 |
analysis_tasks_code = "\n".join([f" {PREDEFINED_ANALYSIS[task]['Function']}(df)" for task in analysis_tasks])
|
| 143 |
+
|
| 144 |
+
# The exception handling block has been removed as per your request
|
| 145 |
code = f"""import streamlit as st
|
| 146 |
import pandas as pd
|
| 147 |
import seaborn as sns
|
|
|
|
| 150 |
{requirements}
|
| 151 |
|
| 152 |
def main():
|
| 153 |
+
st.title("{app_title}")
|
| 154 |
+
st.subheader("{app_subtitle}")
|
| 155 |
+
st.sidebar.title("{side_panel_title}")
|
|
|
|
| 156 |
|
| 157 |
+
uploaded_file = st.file_uploader("Upload a CSV file", type=["csv"])
|
| 158 |
|
| 159 |
+
if uploaded_file is not None:
|
| 160 |
+
@st.cache
|
| 161 |
+
def load_data(uploaded_file):
|
| 162 |
+
return pd.read_csv(uploaded_file)
|
| 163 |
|
| 164 |
+
df = load_data(uploaded_file)
|
| 165 |
|
| 166 |
{analysis_functions_code}
|
| 167 |
+
|
| 168 |
+
# Analysis task calls
|
| 169 |
{analysis_tasks_code}
|
| 170 |
|
| 171 |
if __name__ == "__main__":
|