SantanuBanerjee commited on
Commit
3e19acf
·
verified ·
1 Parent(s): af1e983

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -20
app.py CHANGED
@@ -626,19 +626,19 @@ def process_excel(file):
626
  try: # Meta AI Solution
627
  # Convert project_proposals dictionary to DataFrame
628
  project_proposals_df = pd.DataFrame(list(project_proposals.items()), columns=['Location_Cluster_Problem_Cluster', 'Solutions Proposed'])
629
- consoleMessage_and_Print("CheckPoint 1")
630
 
631
  # Split the composite key into separate columns
632
  project_proposals_df[['Location_Cluster', 'Problem_Cluster']] = project_proposals_df['Location_Cluster_Problem_Cluster'].apply(pd.Series)
633
- consoleMessage_and_Print("CheckPoint 2")
634
 
635
  # Drop the composite key column
636
  project_proposals_df.drop('Location_Cluster_Problem_Cluster', axis=1, inplace=True)
637
- consoleMessage_and_Print("CheckPoint 3")
638
 
639
  # Reorder the columns
640
  project_proposals_df = project_proposals_df[['Location_Cluster', 'Problem_Cluster', 'Solutions Proposed']]
641
- consoleMessage_and_Print("CheckPoint 4")
642
 
643
  except Exception as e:
644
  consoleMessage_and_Print("Meta AI Solution did not work, trying CHATGPT solution")
@@ -685,30 +685,28 @@ def process_excel(file):
685
  output_filename = "OutPut_PPs.xlsx"
686
  with pd.ExcelWriter(output_filename) as writer:
687
  processed_df.to_excel(writer, sheet_name='Input_Processed', index=False)
688
-
 
689
  try:
690
  project_proposals_df.to_excel(writer, sheet_name='Project_Proposals', index=False)
691
  except Exception as e:
692
  consoleMessage_and_Print("Error during Project Proposal excelling at the end")
693
 
694
- budget_cluster_df.to_excel(writer, sheet_name='Financial_Weights')
695
- problem_cluster_df.to_excel(writer, sheet_name='Problem_Descriptions')
696
-
697
 
698
 
699
 
700
- # # Ensure location_clusters and problem_clusters are in DataFrame format
701
- # if isinstance(location_clusters, pd.DataFrame):
702
- # location_clusters.to_excel(writer, sheet_name='Location_Clusters', index=False)
703
- # else:
704
- # consoleMessage_and_Print("Converting Location Clusters to df")
705
- # pd.DataFrame(location_clusters).to_excel(writer, sheet_name='Location_Clusters', index=False)
706
 
707
- # if isinstance(problem_clusters, pd.DataFrame):
708
- # problem_clusters.to_excel(writer, sheet_name='Problem_Clusters', index=False)
709
- # else:
710
- # consoleMessage_and_Print("Converting Problem Clusters to df")
711
- # pd.DataFrame(problem_clusters).to_excel(writer, sheet_name='Problem_Clusters', index=False)
712
 
713
 
714
 
@@ -747,7 +745,7 @@ interface = gr.Interface(
747
 
748
  outputs=[
749
  gr.File(label="Download the processed Excel File containing the ** Project Proposals ** for each Location~Problem paired combination"), # File download output
750
- gr.Textbox(label="Console Messages", lines=15, interactive=False) # Console messages output
751
  ],
752
 
753
 
 
626
  try: # Meta AI Solution
627
  # Convert project_proposals dictionary to DataFrame
628
  project_proposals_df = pd.DataFrame(list(project_proposals.items()), columns=['Location_Cluster_Problem_Cluster', 'Solutions Proposed'])
629
+ # consoleMessage_and_Print("CheckPoint 1")
630
 
631
  # Split the composite key into separate columns
632
  project_proposals_df[['Location_Cluster', 'Problem_Cluster']] = project_proposals_df['Location_Cluster_Problem_Cluster'].apply(pd.Series)
633
+ # consoleMessage_and_Print("CheckPoint 2")
634
 
635
  # Drop the composite key column
636
  project_proposals_df.drop('Location_Cluster_Problem_Cluster', axis=1, inplace=True)
637
+ # consoleMessage_and_Print("CheckPoint 3")
638
 
639
  # Reorder the columns
640
  project_proposals_df = project_proposals_df[['Location_Cluster', 'Problem_Cluster', 'Solutions Proposed']]
641
+ # consoleMessage_and_Print("CheckPoint 4")
642
 
643
  except Exception as e:
644
  consoleMessage_and_Print("Meta AI Solution did not work, trying CHATGPT solution")
 
685
  output_filename = "OutPut_PPs.xlsx"
686
  with pd.ExcelWriter(output_filename) as writer:
687
  processed_df.to_excel(writer, sheet_name='Input_Processed', index=False)
688
+ budget_cluster_df.to_excel(writer, sheet_name='Financial_Weights')
689
+ problem_cluster_df.to_excel(writer, sheet_name='Problem_Descriptions')
690
  try:
691
  project_proposals_df.to_excel(writer, sheet_name='Project_Proposals', index=False)
692
  except Exception as e:
693
  consoleMessage_and_Print("Error during Project Proposal excelling at the end")
694
 
 
 
 
695
 
696
 
697
 
698
+ # Ensure location_clusters and problem_clusters are in DataFrame format
699
+ if isinstance(location_clusters, pd.DataFrame):
700
+ location_clusters.to_excel(writer, sheet_name='Location_Clusters', index=False)
701
+ else:
702
+ consoleMessage_and_Print("Converting Location Clusters to df")
703
+ pd.DataFrame(location_clusters).to_excel(writer, sheet_name='Location_Clusters', index=False)
704
 
705
+ if isinstance(problem_clusters, pd.DataFrame):
706
+ problem_clusters.to_excel(writer, sheet_name='Problem_Clusters', index=False)
707
+ else:
708
+ consoleMessage_and_Print("Converting Problem Clusters to df")
709
+ pd.DataFrame(problem_clusters).to_excel(writer, sheet_name='Problem_Clusters', index=False)
710
 
711
 
712
 
 
745
 
746
  outputs=[
747
  gr.File(label="Download the processed Excel File containing the ** Project Proposals ** for each Location~Problem paired combination"), # File download output
748
+ gr.Textbox(label="Console Messages", lines=10, interactive=False) # Console messages output
749
  ],
750
 
751