Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -140,7 +140,7 @@ 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
|
|
@@ -157,18 +157,16 @@ def main():
|
|
| 157 |
uploaded_file = st.file_uploader("Upload a CSV file", type=["csv"])
|
| 158 |
|
| 159 |
if uploaded_file is not None:
|
| 160 |
-
@st.
|
| 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 |
-
except Exception as e:
|
| 171 |
-
st.error(f"An error occurred: {str(e)}")
|
| 172 |
|
| 173 |
if __name__ == "__main__":
|
| 174 |
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 |
code = f"""import streamlit as st
|
| 145 |
import pandas as pd
|
| 146 |
import seaborn as sns
|
|
|
|
| 157 |
uploaded_file = st.file_uploader("Upload a CSV file", type=["csv"])
|
| 158 |
|
| 159 |
if uploaded_file is not None:
|
| 160 |
+
@st.cache_data
|
| 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__":
|
| 172 |
main()
|