mtyrrell commited on
Commit
8f49843
·
1 Parent(s): 3a17c13

Excel output

Browse files
Files changed (3) hide show
  1. app.py +13 -9
  2. images/pipeline.png +0 -0
  3. modules/org_count.py +4 -0
app.py CHANGED
@@ -21,8 +21,9 @@ from modules.utils import create_excel, clean_text, extract_predicted_labels, pr
21
  from modules.logging_config import setup_logging
22
  setup_logging()
23
  import logging
24
- logger = logging.getLogger(__name__)
25
 
 
26
 
27
  # Local
28
  # from dotenv import load_dotenv
@@ -141,21 +142,24 @@ def main():
141
 
142
  df = st.session_state['df']
143
 
144
- current_datetime = datetime.now().strftime('%d-%m-%Y_%H-%M-%S')
145
- output_filename = f'processed_applications_{current_datetime}.csv'
146
- csv_buffer = df.to_csv(index=False).encode()
147
- logger.info("CSV buffer created successfully")
148
-
149
  def reset_button_state():
150
  st.session_state['show_button'] = True
151
  st.session_state['processing'] = False
152
  st.session_state['data_processed'] = False
153
 
 
 
 
 
 
 
 
 
154
  st.download_button(
155
- label="Download data as CSV",
156
- data=csv_buffer,
157
  file_name=output_filename,
158
- mime='text/csv',
159
  on_click=reset_button_state
160
  )
161
 
 
21
  from modules.logging_config import setup_logging
22
  setup_logging()
23
  import logging
24
+ from io import BytesIO
25
 
26
+ logger = logging.getLogger(__name__)
27
 
28
  # Local
29
  # from dotenv import load_dotenv
 
142
 
143
  df = st.session_state['df']
144
 
 
 
 
 
 
145
  def reset_button_state():
146
  st.session_state['show_button'] = True
147
  st.session_state['processing'] = False
148
  st.session_state['data_processed'] = False
149
 
150
+ # Create Excel buffer
151
+ excel_buffer = BytesIO()
152
+ df.to_excel(excel_buffer, index=False, engine='openpyxl')
153
+ excel_buffer.seek(0)
154
+
155
+ current_datetime = datetime.now().strftime('%d-%m-%Y_%H-%M-%S')
156
+ output_filename = f'processed_applications_{current_datetime}.xlsx'
157
+
158
  st.download_button(
159
+ label="Download Analysis Data File",
160
+ data=excel_buffer,
161
  file_name=output_filename,
162
+ mime='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
163
  on_click=reset_button_state
164
  )
165
 
images/pipeline.png CHANGED
modules/org_count.py CHANGED
@@ -34,9 +34,11 @@ def standardize_organization_names(df):
34
  'Brazilian Tourist Board': ['brazilian tourist board'],
35
  'Caribbean Community Climate Change Centre': ['caribbean community climate'],
36
  'Caritas': ['caritas'],
 
37
  'Climate Advocacy International (CAI)': ['climate advocacy int'],
38
  'Deutsche Gesellschaft für Internationale Zusammenarbeit (GIZ)': ['deutsche gesellschaft für internationale'],
39
  'Deutsche Sparkassenstiftung (DSIK)': ['deutsche sparkassenstiftung'],
 
40
  'East African Centre of Excellence for Renewable Energy and Efficiency (EACREEE)': ['east african centre of excellence for renewable'],
41
  'Eco-Ideal': ['eco-ideal'],
42
  'Global Green Growth Institute (GGGI)': ['global green growth'],
@@ -44,6 +46,7 @@ def standardize_organization_names(df):
44
  'Iskandar Regional Development Authority (IRDA)': ['iskandar regional'],
45
  'Islamic Development Bank': ['islamic development bank'],
46
  'Malaysian Industry Government Group for High Technology (MIGHT)': ['government group for high technology'],
 
47
  'Osh Technological University': ['osh technological university','ошский технологический университет'],
48
  'Oxford Policy Management (OPM)': ['oxford policy management'],
49
  'Pacific Rim Investment Management': ['pacific rim investment'],
@@ -75,6 +78,7 @@ def standardize_organization_names(df):
75
  org_abreviations = {
76
  'Deutsche Gesellschaft für Internationale Zusammenarbeit (GIZ)': ['GIZ'],
77
  'Deutsche Sparkassenstiftung (DSIK)': ['DSIK'],
 
78
  'East African Centre of Excellence for Renewable Energy and Efficiency (EACREEE)': ['EACREEE'],
79
  'Global Green Growth Institute (GGGI)': ['GGGI'],
80
  'UN-Habitat': ['UN-Habitat'],
 
34
  'Brazilian Tourist Board': ['brazilian tourist board'],
35
  'Caribbean Community Climate Change Centre': ['caribbean community climate'],
36
  'Caritas': ['caritas'],
37
+ 'Chemical Industries Holding Company': ['chemical industries holding company'],
38
  'Climate Advocacy International (CAI)': ['climate advocacy int'],
39
  'Deutsche Gesellschaft für Internationale Zusammenarbeit (GIZ)': ['deutsche gesellschaft für internationale'],
40
  'Deutsche Sparkassenstiftung (DSIK)': ['deutsche sparkassenstiftung'],
41
+ 'Development Initiative for Community Impact (DICI)': ['development initiative for community impact'],
42
  'East African Centre of Excellence for Renewable Energy and Efficiency (EACREEE)': ['east african centre of excellence for renewable'],
43
  'Eco-Ideal': ['eco-ideal'],
44
  'Global Green Growth Institute (GGGI)': ['global green growth'],
 
46
  'Iskandar Regional Development Authority (IRDA)': ['iskandar regional'],
47
  'Islamic Development Bank': ['islamic development bank'],
48
  'Malaysian Industry Government Group for High Technology (MIGHT)': ['government group for high technology'],
49
+ 'Metallurgical Industries Holding Company': ['metallurgical industries holding company'],
50
  'Osh Technological University': ['osh technological university','ошский технологический университет'],
51
  'Oxford Policy Management (OPM)': ['oxford policy management'],
52
  'Pacific Rim Investment Management': ['pacific rim investment'],
 
78
  org_abreviations = {
79
  'Deutsche Gesellschaft für Internationale Zusammenarbeit (GIZ)': ['GIZ'],
80
  'Deutsche Sparkassenstiftung (DSIK)': ['DSIK'],
81
+ 'Development Initiative for Community Impact (DICI)': ['DICI'],
82
  'East African Centre of Excellence for Renewable Energy and Efficiency (EACREEE)': ['EACREEE'],
83
  'Global Green Growth Institute (GGGI)': ['GGGI'],
84
  'UN-Habitat': ['UN-Habitat'],