Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,8 +8,18 @@ import base64
|
|
| 8 |
|
| 9 |
def advanced_analysis(file):
|
| 10 |
try:
|
| 11 |
-
#
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
# Comprehensive Analysis Report
|
| 15 |
report = "# π Comprehensive Data Analysis Report\n\n"
|
|
@@ -147,16 +157,16 @@ demo = gr.Interface(
|
|
| 147 |
fn=advanced_analysis,
|
| 148 |
inputs=gr.File(
|
| 149 |
type="filepath",
|
| 150 |
-
label="π€ Upload
|
| 151 |
file_count="single",
|
| 152 |
-
file_types=["csv"]
|
| 153 |
),
|
| 154 |
outputs=[
|
| 155 |
-
gr.Markdown(),
|
| 156 |
gr.Image(label="π Advanced Visualizations")
|
| 157 |
],
|
| 158 |
title="π§ Smart Data Analyzer",
|
| 159 |
-
description="Upload a CSV file for comprehensive data analysis, statistical insights, and interactive visualizations.",
|
| 160 |
theme='default',
|
| 161 |
css=css
|
| 162 |
)
|
|
|
|
| 8 |
|
| 9 |
def advanced_analysis(file):
|
| 10 |
try:
|
| 11 |
+
# Support multiple file types
|
| 12 |
+
supported_extensions = ['.csv', '.xlsx', '.xls', '.txt']
|
| 13 |
+
if not any(file.lower().endswith(ext) for ext in supported_extensions):
|
| 14 |
+
raise ValueError(f"Unsupported file type. Please upload a file with one of these extensions: {', '.join(supported_extensions)}")
|
| 15 |
+
|
| 16 |
+
# Load file based on extension
|
| 17 |
+
if file.endswith('.csv'):
|
| 18 |
+
df = pd.read_csv(file)
|
| 19 |
+
elif file.endswith(('.xlsx', '.xls')):
|
| 20 |
+
df = pd.read_excel(file)
|
| 21 |
+
elif file.endswith('.txt'):
|
| 22 |
+
df = pd.read_csv(file, sep='\t')
|
| 23 |
|
| 24 |
# Comprehensive Analysis Report
|
| 25 |
report = "# π Comprehensive Data Analysis Report\n\n"
|
|
|
|
| 157 |
fn=advanced_analysis,
|
| 158 |
inputs=gr.File(
|
| 159 |
type="filepath",
|
| 160 |
+
label="π€ Upload File",
|
| 161 |
file_count="single",
|
| 162 |
+
file_types=["csv", "xlsx", "xls", "txt"] # Updated file types
|
| 163 |
),
|
| 164 |
outputs=[
|
| 165 |
+
gr.Markdown(),
|
| 166 |
gr.Image(label="π Advanced Visualizations")
|
| 167 |
],
|
| 168 |
title="π§ Smart Data Analyzer",
|
| 169 |
+
description="Upload a CSV, Excel, or Text file for comprehensive data analysis, statistical insights, and interactive visualizations.",
|
| 170 |
theme='default',
|
| 171 |
css=css
|
| 172 |
)
|