rameshmoorthy
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -110,29 +110,48 @@ def generate_report(file, type):
|
|
110 |
temp_file3.write(contents.encode('utf-8'))
|
111 |
temp_file3.close()
|
112 |
try:
|
113 |
-
|
114 |
-
AV =
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
header=0,
|
122 |
-
verbose=2,
|
123 |
-
lowess=False,
|
124 |
-
chart_format="html",
|
125 |
-
max_rows_analyzed=500,
|
126 |
-
max_cols_analyzed=20,
|
127 |
-
save_plot_dir="plots"
|
128 |
-
)
|
129 |
except Exception as e:
|
130 |
dfviz=df
|
131 |
print(e)
|
132 |
print('Exception during Autoviz')
|
133 |
|
134 |
-
|
135 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
136 |
|
137 |
dfs = DataFrameSummary(df)
|
138 |
sd=dfs.summary()
|
@@ -150,7 +169,7 @@ def generate_report(file, type):
|
|
150 |
|
151 |
|
152 |
|
153 |
-
return temp_file1.name ,temp_file3.name ,variable_table(df),dfviz,sd1
|
154 |
|
155 |
def handle_click(file, sheet_name):
|
156 |
|
@@ -198,8 +217,37 @@ with gr.Blocks() as cluster:
|
|
198 |
gr.HTML(value="""<h2 style="color: #BA4A00; text-shadow: 1px 1px 2px #ddd;"COLUMNS STATS AND ANALYSIS</h2>""")
|
199 |
#gr.Markdown("#Columns Analysis")
|
200 |
dataframe2=gr.Dataframe()
|
201 |
-
|
202 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
203 |
file.change(update_sheets, inputs=file, outputs=sheet_dropdown)
|
204 |
#btn.click(generate_report,inputs=[file],outputs=[out1,out2,var,dataframe1,dataframe2])
|
205 |
cluster.launch()
|
|
|
110 |
temp_file3.write(contents.encode('utf-8'))
|
111 |
temp_file3.close()
|
112 |
try:
|
113 |
+
df=AV.AutoViz('/content/insurance.csv')
|
114 |
+
dft = AV.AutoViz(filename="", sep=',', dfte=df, header=0, verbose=1,
|
115 |
+
lowess=False,chart_format='html',max_rows_analyzed=150000,
|
116 |
+
max_cols_analyzed=30,save_plot_dir="plots_html")
|
117 |
+
dft = AV.AutoViz(filename='/content/insurance.csv', sep=',', header=0, verbose=2,
|
118 |
+
lowess=False,chart_format='png',max_rows_analyzed=150000,
|
119 |
+
max_cols_analyzed=30,save_plot_dir="plots")
|
120 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
121 |
except Exception as e:
|
122 |
dfviz=df
|
123 |
print(e)
|
124 |
print('Exception during Autoviz')
|
125 |
|
126 |
+
reports = []
|
127 |
+
output_dir_html='plots_html/AutoViz'
|
128 |
+
for filename in os.listdir(output_dir_html):
|
129 |
+
if filename.endswith(".html"):
|
130 |
+
title = os.path.splitext(filename)[0] # Extract title from filename (without extension)
|
131 |
+
reports.append(title)
|
132 |
+
reports.append(output_dir_html+'/'+filename)
|
133 |
+
imgs = []
|
134 |
+
output_dir_img='plots/Autoviz'
|
135 |
+
for filename in os.listdir(output_dir_img):
|
136 |
+
if filename.endswith(".png"):
|
137 |
+
title = os.path.splitext(filename)[0] # Extract title from filename (without extension)
|
138 |
+
imgs.append(title)
|
139 |
+
imgs.append(output_dir_img+'/'+filename)
|
140 |
+
while len(reports)<10:
|
141 |
+
# Comparing the lengths and appending t and m to output if needed
|
142 |
+
|
143 |
+
t = gr.Markdown(visible=False)
|
144 |
+
m = gr.File(visible=False)
|
145 |
+
reports.append(t)
|
146 |
+
reports.append(m)
|
147 |
+
|
148 |
+
while len(imgs)<10:
|
149 |
+
# Comparing the lengths and appending t and m to output if needed
|
150 |
+
|
151 |
+
t = gr.Markdown(visible=False)
|
152 |
+
m = gr.Image(visible=False)
|
153 |
+
imgs.append(t)
|
154 |
+
imgs.append(m)
|
155 |
|
156 |
dfs = DataFrameSummary(df)
|
157 |
sd=dfs.summary()
|
|
|
169 |
|
170 |
|
171 |
|
172 |
+
return temp_file1.name ,temp_file3.name ,variable_table(df),dfviz,sd1,reports+imgs
|
173 |
|
174 |
def handle_click(file, sheet_name):
|
175 |
|
|
|
217 |
gr.HTML(value="""<h2 style="color: #BA4A00; text-shadow: 1px 1px 2px #ddd;"COLUMNS STATS AND ANALYSIS</h2>""")
|
218 |
#gr.Markdown("#Columns Analysis")
|
219 |
dataframe2=gr.Dataframe()
|
220 |
+
|
221 |
+
#Autoviz insights graphs
|
222 |
+
with gr.Column():
|
223 |
+
gr.HTML(value="""<h1 style="color: #1999FF; text-shadow: 1px 1px 2px #ddd;">EXCEL ANALYSIS AND INSIGHTS</h1>""")
|
224 |
+
with gr.Row():
|
225 |
+
file = gr.File(file_types=['.csv', '.xlsx'], label="Upload a CSV or Excel file")
|
226 |
+
btn = gr.Button("Download Report")
|
227 |
+
# AutoViz report display section
|
228 |
+
#autoviz_reports = gr.Column()
|
229 |
+
gr.HTML(value="""<h3 style="color: #1999FF; text-shadow: 1px 1px 2px #ddd;">Insight Visualisations</h3>""")
|
230 |
+
with gr.Column():
|
231 |
+
plots2 = []
|
232 |
+
for i in range(5):
|
233 |
+
t = gr.Markdown()
|
234 |
+
with gr.Column(scale=1):
|
235 |
+
m=gr.Image()
|
236 |
+
plots2.append(t)
|
237 |
+
plots2.append(m)
|
238 |
+
print(type(plots1[0]))
|
239 |
+
gr.HTML(value="""<h3 style="color: #1999FF; text-shadow: 1px 1px 2px #ddd;">Insight graphs</h3>""")
|
240 |
+
with gr.Row():
|
241 |
+
plots1 = []
|
242 |
+
for i in range(5):
|
243 |
+
with gr.Row():
|
244 |
+
t = gr.Markdown()
|
245 |
+
m=gr.File()
|
246 |
+
plots1.append(t)
|
247 |
+
plots1.append(m)
|
248 |
+
print(type(plots1[0]))
|
249 |
+
|
250 |
+
btn.click(handle_click, inputs=[file, sheet_dropdown], outputs=[out1, out2, var, dataframe1, dataframe2,plots1+plots2])
|
251 |
file.change(update_sheets, inputs=file, outputs=sheet_dropdown)
|
252 |
#btn.click(generate_report,inputs=[file],outputs=[out1,out2,var,dataframe1,dataframe2])
|
253 |
cluster.launch()
|