File size: 2,072 Bytes
fe475ff
 
 
 
 
 
5191254
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fe475ff
40fc29c
 
5191254
40fc29c
 
 
 
5191254
40fc29c
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import os
import sys
src_directory = os.path.abspath(os.path.join(os.path.dirname(__file__), "../..", "main"))
sys.path.append(src_directory)
import requests_app

def display_contents(option, streamlit):
    try:
        cont = requests_app.get_api(option)
        continents = streamlit.table(cont)
        return continents
    except Exception as e:
        streamlit.error(f"An error occurred while processing the CSV: {e}")

def get_list(option):
    data = requests_app.get_api(option)
    return data["Country"].values()

def choose_data_to_view(st_interface):
    choosen_option = st_interface.sidebar.selectbox(
        "Data Insights",
        options=[
            "Select an option",  
            "Show All Continents",
            "Show Continent Wise Data",
            "Show Continent Stats",
            "Show All Countries",
            "Show Country Data" ,
            "Show Country Stats",
            "Upload Custom CSV"
        ]
    )

    if choosen_option == "Select an option":
        return None  
    return choosen_option

def choose_data_from_list(st_interface,list_option):
    choosen_option = st_interface.sidebar.selectbox(
        "Options",list_option)
    return choosen_option

def choose_stat_to_view(st_interface):
    stat_options = ["Select an option","highest","lowest"]
    selected_option = st_interface.sidebar.selectbox("Select Stat to Display", stat_options)
    return selected_option

def choose_attribute_to_view(st_interface):
    attribute_options = ["Select an option","Population", "Area"]
    selected_option = st_interface.sidebar.selectbox("Select Attribute to Display", attribute_options)
    return selected_option

def display_stats(streamlit,choosen_data):
    clean_choosen_data = choosen_data.replace(" ", "")
    attribute = choose_attribute_to_view(streamlit)
    if attribute in ["Population","Area"] :
        stat = choose_stat_to_view(streamlit)
        if stat in ["highest" , "lowest"]:
            option = f"{clean_choosen_data}/{attribute}/{stat}"
            display_contents(option,streamlit)