Spaces:
Sleeping
Sleeping
Commit
·
788a412
1
Parent(s):
886371d
Update second.py
Browse files
second.py
CHANGED
@@ -85,26 +85,36 @@ def double_main(uploaded_file1,uploaded_file2):
|
|
85 |
|
86 |
|
87 |
# Create a Pandas Excel writer using XlsxWriter as the engine
|
88 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
|
|
|
|
|
|
108 |
|
109 |
# Create a Download Excel button
|
110 |
st.markdown("### Download Excel Report")
|
|
|
85 |
|
86 |
|
87 |
# Create a Pandas Excel writer using XlsxWriter as the engine
|
88 |
+
try:
|
89 |
+
# Create a Pandas Excel writer using XlsxWriter as the engine
|
90 |
+
excel_writer = pd.ExcelWriter('comparison_results.xlsx', engine='xlsxwriter')
|
91 |
+
|
92 |
+
# Write each section to a separate sheet
|
93 |
+
fail_to_fail_scenarios.loc[:, columns_to_display1].to_excel(excel_writer, sheet_name='Consistent Failures', index=False)
|
94 |
+
pass_to_fail_scenarios.loc[:, columns_to_display2].to_excel(excel_writer, sheet_name='New Failures', index=False)
|
95 |
+
fail_to_pass_scenarios.loc[:, columns_to_display3].to_excel(excel_writer, sheet_name='New Passes', index=False)
|
96 |
|
97 |
+
# Add a sheet to store information about CSV versions
|
98 |
+
csv_version_sheet = excel_writer.book.add_worksheet('CSV Details')
|
99 |
+
|
100 |
+
# Write the CSV version information
|
101 |
+
csv_version_sheet.write('A1', 'Older CSV:')
|
102 |
+
csv_version_sheet.write('B1', 'Newer CSV:')
|
103 |
+
csv_version_sheet.write('A2', older_df['Start datetime'].min().strftime('%Y-%m-%d %H:%M:%S'))
|
104 |
+
csv_version_sheet.write('B2', newer_df['Start datetime'].min().strftime('%Y-%m-%d %H:%M:%S'))
|
105 |
+
|
106 |
+
except Exception as e:
|
107 |
+
print(f"Error encountered: {e}")
|
108 |
+
# Handle or print the error
|
109 |
+
pass
|
110 |
+
|
111 |
+
try:
|
112 |
+
# Save the Excel file
|
113 |
+
excel_writer.save()
|
114 |
+
except Exception as e:
|
115 |
+
print(f"Error encountered during saving: {e}")
|
116 |
+
# Handle or print the error
|
117 |
+
pass
|
118 |
|
119 |
# Create a Download Excel button
|
120 |
st.markdown("### Download Excel Report")
|