annikwag commited on
Commit
f7d0726
·
verified ·
1 Parent(s): 77a1d81

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -23
app.py CHANGED
@@ -255,16 +255,11 @@ if show_exact_matches:
255
  except json.JSONDecodeError:
256
  c_list = []
257
 
258
- # Only keep country names if the region lookup (get_country_name)
259
- # returns something different than the raw code.
260
  matched_countries = []
261
  for code in c_list:
262
  if len(code) == 2:
263
  resolved_name = get_country_name(code.upper(), region_df)
264
- # If get_country_name didn't find a match,
265
- # it typically just returns the same code (like "XX").
266
- # We'll consider "successfully looked up" if
267
- # resolved_name != code.upper().
268
  if resolved_name.upper() != code.upper():
269
  matched_countries.append(resolved_name)
270
 
@@ -275,13 +270,27 @@ if show_exact_matches:
275
  formatted_project_budget = format_currency(total_project)
276
  formatted_total_volume = format_currency(total_volume)
277
 
278
- additional_text = (
279
- f"Commissioned by **{client_name}**\n"
280
-
281
- f"Projekt duration **{start_year_str}-{end_year_str}**\n"
282
-
283
- f"Budget: Project: **{formatted_project_budget}**, Total volume: **{formatted_total_volume}**"
284
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
285
  st.markdown(additional_text)
286
  st.divider()
287
 
@@ -330,16 +339,10 @@ else:
330
  except json.JSONDecodeError:
331
  c_list = []
332
 
333
- # Only keep country names if the region lookup (get_country_name)
334
- # returns something different than the raw code.
335
  matched_countries = []
336
  for code in c_list:
337
  if len(code) == 2:
338
  resolved_name = get_country_name(code.upper(), region_df)
339
- # If get_country_name didn't find a match,
340
- # it typically just returns the same code (like "XX").
341
- # We'll consider "successfully looked up" if
342
- # resolved_name != code.upper().
343
  if resolved_name.upper() != code.upper():
344
  matched_countries.append(resolved_name)
345
 
@@ -354,11 +357,13 @@ else:
354
  # Build the final string
355
  if matched_countries:
356
  additional_text = (
357
- f"**{', '.join(matched_countries)} f"Commissioned by **{client_name}**\n"
358
 
359
  f"Projekt duration **{start_year_str}-{end_year_str}**\n"
360
 
361
- f"Budget: Project: **{formatted_project_budget}**, Total volume: **{formatted_total_volume}**"
 
 
362
  )
363
  else:
364
  additional_text = (
@@ -366,10 +371,11 @@ else:
366
 
367
  f"Projekt duration **{start_year_str}-{end_year_str}**\n"
368
 
369
- f"Budget: Project: **{formatted_project_budget}**, Total volume: **{formatted_total_volume}**"
 
 
370
  )
371
 
372
-
373
  st.markdown(additional_text)
374
  st.divider()
375
 
 
255
  except json.JSONDecodeError:
256
  c_list = []
257
 
258
+ # Only keep country names if the region lookup returns a different value.
 
259
  matched_countries = []
260
  for code in c_list:
261
  if len(code) == 2:
262
  resolved_name = get_country_name(code.upper(), region_df)
 
 
 
 
263
  if resolved_name.upper() != code.upper():
264
  matched_countries.append(resolved_name)
265
 
 
270
  formatted_project_budget = format_currency(total_project)
271
  formatted_total_volume = format_currency(total_volume)
272
 
273
+ # Build the final string including a new row for countries.
274
+ if matched_countries:
275
+ additional_text = (
276
+ f"**{', '.join(matched_countries)}**, commissioned by **{client_name}**\n"
277
+
278
+ f"Projekt duration **{start_year_str}-{end_year_str}**\n"
279
+
280
+ f"Budget: Project: **{formatted_project_budget}**, Total volume: **{formatted_total_volume}**\n"
281
+
282
+ f"Country: **{', '.join(matched_countries)}**"
283
+ )
284
+ else:
285
+ additional_text = (
286
+ f"Commissioned by **{client_name}**\n"
287
+
288
+ f"Projekt duration **{start_year_str}-{end_year_str}**\n"
289
+
290
+ f"Budget: Project: **{formatted_project_budget}**, Total volume: **{formatted_total_volume}**\n"
291
+
292
+ f"Country: **{', '.join(c_list) if c_list else 'Unknown'}**"
293
+ )
294
  st.markdown(additional_text)
295
  st.divider()
296
 
 
339
  except json.JSONDecodeError:
340
  c_list = []
341
 
 
 
342
  matched_countries = []
343
  for code in c_list:
344
  if len(code) == 2:
345
  resolved_name = get_country_name(code.upper(), region_df)
 
 
 
 
346
  if resolved_name.upper() != code.upper():
347
  matched_countries.append(resolved_name)
348
 
 
357
  # Build the final string
358
  if matched_countries:
359
  additional_text = (
360
+ f"**{', '.join(matched_countries)}**, commissioned by **{client_name}**\n"
361
 
362
  f"Projekt duration **{start_year_str}-{end_year_str}**\n"
363
 
364
+ f"Budget: Project: **{formatted_project_budget}**, Total volume: **{formatted_total_volume}**\n"
365
+
366
+ f"Country: **{', '.join(matched_countries)}**"
367
  )
368
  else:
369
  additional_text = (
 
371
 
372
  f"Projekt duration **{start_year_str}-{end_year_str}**\n"
373
 
374
+ f"Budget: Project: **{formatted_project_budget}**, Total volume: **{formatted_total_volume}**\n"
375
+
376
+ f"Country: **{', '.join(c_list) if c_list else 'Unknown'}**"
377
  )
378
 
 
379
  st.markdown(additional_text)
380
  st.divider()
381