Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -151,8 +151,16 @@ def generate_report(file, type):
|
|
| 151 |
|
| 152 |
|
| 153 |
return temp_file1.name ,temp_file3.name ,variable_table(df),dfviz,sd1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 154 |
|
| 155 |
-
|
|
|
|
|
|
|
|
|
|
| 156 |
with gr.Blocks() as cluster:
|
| 157 |
with gr.Column():
|
| 158 |
gr.HTML(value="""<h1 style="color: #1999FF; text-shadow: 1px 1px 2px #ddd;">EXCEL ANALYSIS AND INSIGHTS</h1>""")
|
|
@@ -167,6 +175,11 @@ with gr.Blocks() as cluster:
|
|
| 167 |
out1=gr.File(label="Download CSV")
|
| 168 |
gr.HTML(value="""<h2 style="color: #3399FF; text-shadow: 1px 1px 2px #ddd;">SWEETVIZ REPORT</h2>""")
|
| 169 |
out2=gr.File(label="Download CSV")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 170 |
with gr.Column()
|
| 171 |
gr.HTML(value="""<h2 style="color: #BA4A00; text-shadow: 1px 1px 2px #ddd;"COLUMNS IN FILE</h2>"""):
|
| 172 |
#gr.Markdown("***Uploaded File***")
|
|
@@ -179,5 +192,8 @@ with gr.Blocks() as cluster:
|
|
| 179 |
gr.HTML(value="""<h2 style="color: #BA4A00; text-shadow: 1px 1px 2px #ddd;"COLUMNS STATS AND ANALYSIS</h2>"""):
|
| 180 |
#gr.Markdown("#Columns Analysis")
|
| 181 |
dataframe2=gr.Dataframe()
|
| 182 |
-
|
|
|
|
|
|
|
|
|
|
| 183 |
cluster.launch()
|
|
|
|
| 151 |
|
| 152 |
|
| 153 |
return temp_file1.name ,temp_file3.name ,variable_table(df),dfviz,sd1
|
| 154 |
+
def handle_click(file, sheet_name):
|
| 155 |
+
sheet_dropdown.update(disabled=True) # Disable during report generation
|
| 156 |
+
results = generate_report(file, sheet_name)
|
| 157 |
+
sheet_dropdown.update(disabled=False) # Re-enable sheet selection
|
| 158 |
+
return results
|
| 159 |
|
| 160 |
+
def update_sheets(file):
|
| 161 |
+
sheet_names = pd.ExcelFile(file).sheet_names
|
| 162 |
+
sheet_dropdown.update(options=sheet_names, disabled=False)
|
| 163 |
+
|
| 164 |
with gr.Blocks() as cluster:
|
| 165 |
with gr.Column():
|
| 166 |
gr.HTML(value="""<h1 style="color: #1999FF; text-shadow: 1px 1px 2px #ddd;">EXCEL ANALYSIS AND INSIGHTS</h1>""")
|
|
|
|
| 175 |
out1=gr.File(label="Download CSV")
|
| 176 |
gr.HTML(value="""<h2 style="color: #3399FF; text-shadow: 1px 1px 2px #ddd;">SWEETVIZ REPORT</h2>""")
|
| 177 |
out2=gr.File(label="Download CSV")
|
| 178 |
+
sheet_dropdown = gr.Dropdown(
|
| 179 |
+
label="Select sheet", options=[], disabled=True # Initially disabled
|
| 180 |
+
)
|
| 181 |
+
|
| 182 |
+
|
| 183 |
with gr.Column()
|
| 184 |
gr.HTML(value="""<h2 style="color: #BA4A00; text-shadow: 1px 1px 2px #ddd;"COLUMNS IN FILE</h2>"""):
|
| 185 |
#gr.Markdown("***Uploaded File***")
|
|
|
|
| 192 |
gr.HTML(value="""<h2 style="color: #BA4A00; text-shadow: 1px 1px 2px #ddd;"COLUMNS STATS AND ANALYSIS</h2>"""):
|
| 193 |
#gr.Markdown("#Columns Analysis")
|
| 194 |
dataframe2=gr.Dataframe()
|
| 195 |
+
|
| 196 |
+
btn.click(handle_click, inputs=[file, sheet_dropdown], outputs=[out1, out2, var, dataframe1, dataframe2])
|
| 197 |
+
file.observe(update_sheets, names=["data"])
|
| 198 |
+
#btn.click(generate_report,inputs=[file],outputs=[out1,out2,var,dataframe1,dataframe2])
|
| 199 |
cluster.launch()
|