from csv import DictReader PATH = "src/electricity_mix.csv" COUNTRY_CODES = [ ("🌎 World", "WOR"), ("🇪🇺 Europe", "EEE"), ("🇿🇼 Zimbabwe", "ZWE"), ("🇿🇲 Zambia", "ZMB"), ("🇿🇦 South Africa", "ZAF"), ("🇾🇪 Yemen", "YEM"), ("🇻🇳 Vietnam", "VNM"), ("🇻🇪 Venezuela", "VEN"), ("🇺🇿 Uzbekistan", "UZB"), ("🇺🇾 Uruguay", "URY"), ("🇺🇸 United States", "USA"), ("🇺🇦 Ukraine", "UKR"), ("🇹🇿 Tanzania", "TZA"), ("🇹🇼 Taiwan", "TWN"), ("🇹🇹 Trinidad and Tobago", "TTO"), ("🇹🇷 Turkey", "TUR"), ("🇹🇳 Tunisia", "TUN"), ("🇹🇲 Turkmenistan", "TKM"), ("🇹🇯 Tajikistan", "TJK"), ("🇹🇭 Thailand", "THA"), ("🇹🇬 Togo", "TGO"), ("🇸🇾 Syrian Arab Republic", "SYR"), ("🇸🇻 El Salvador", "SLV"), ("🇸🇳 Senegal", "SEN"), ("🇸🇰 Slovak Republic", "SVK"), ("🇸🇮 Slovenia", "SVN"), ("🇸🇬 Singapore", "SGP"), ("🇸🇪 Sweden", "SWE"), ("🇸🇩 Sudan", "SDN"), ("🇸🇦 Saudi Arabia", "SAU"), ("🇷🇺 Russian Federation", "RUS"), ("🇷🇸 Serbia and Montenegro", "SCG"), ("🇷🇴 Romania", "ROU"), ("🇶🇦 Qatar", "QAT"), ("🇵🇾 Paraguay", "PRY"), ("🇵🇹 Portugal", "PRT"), ("🇵🇱 Poland", "POL"), ("🇵🇰 Pakistan", "PAK"), ("🇵🇭 Philippines", "PHL"), ("🇵🇪 Peru", "PER"), ("🇵🇦 Panama", "PAN"), ("🇴🇲 Oman", "OMN"), ("🇳🇿 New Zealand", "NZL"), ("🇳🇵 Nepal", "NPL"), ("🇳🇴 Norway", "NOR"), ("🇳🇱 Netherlands", "NLD"), ("🇳🇮 Nicaragua", "NIC"), ("🇳🇬 Nigeria", "NGA"), ("🇳🇦 Namibia", "NAM"), ("🇲🇿 Mozambique", "MOZ"), ("🇲🇾 Malaysia", "MYS"), ("🇲🇽 Mexico", "MEX"), ("🇲🇹 Malta", "MLT"), ("🇲🇳 Mongolia", "MNG"), ("🇲🇲 Myanmar", "MMR"), ("🇲🇰 North Macedonia", "MKD"), ("🇲🇩 Moldova", "MDA"), ("🇲🇦 Morocco", "MAR"), ("🇱🇾 Libya", "LBY"), ("🇱🇻 Latvia", "LVA"), ("🇱🇺 Luxembourg", "LUX"), ("🇱🇹 Lithuania", "LTU"), ("🇱🇰 Sri Lanka", "LKA"), ("🇱🇧 Lebanon", "LBN"), ("🇰🇿 Kazakhstan", "KAZ"), ("🇰🇼 Kuwait", "KWT"), ("🇰🇷 South Korea", "KOR"), ("🇰🇵 North Korea", "PRK"), ("🇰🇭 Cambodia", "KHM"), ("🇰🇬 Kyrgyz Republic", "KGZ"), ("🇰🇪 Kenya", "KEN"), ("🇯🇵 Japan", "JPN"), ("🇯🇴 Jordan", "JOR"), ("🇯🇲 Jamaica", "JAM"), ("🇮🇹 Italy", "ITA"), ("🇮🇸 Iceland", "ISL"), ("🇮🇷 Iran", "IRN"), ("🇮🇶 Iraq", "IRQ"), ("🇮🇳 India", "IND"), ("🇮🇱 Israel", "ISR"), ("🇮🇪 Ireland", "IRL"), ("🇮🇩 Indonesia", "IDN"), ("🇭🇺 Hungary", "HUN"), ("🇭🇹 Haiti", "HTI"), ("🇭🇷 Croatia", "HRV"), ("🇭🇳 Honduras", "HND"), ("🇭🇰 Hong Kong", "HKG"), ("🇬🇹 Guatemala", "GTM"), ("🇬🇷 Greece", "GRC"), ("🇬🇮 Gibraltar", "GIB"), ("🇬🇭 Ghana", "GHA"), ("🇬🇪 Georgia", "GEO"), ("🇬🇧 United Kingdom", "GBR"), ("🇬🇦 Gabon", "GAB"), ("🇫🇷 France", "FRA"), ("🇫🇮 Finland", "FIN"), ("🇪🇹 Ethiopia", "ETH"), ("🇪🇸 Spain", "ESP"), ("🇪🇷 Eritrea", "ERI"), ("🇪🇬 Egypt", "EGY"), ("🇪🇪 Estonia", "EST"), ("🇪🇨 Ecuador", "ECU"), ("🇩🇿 Algeria", "DZA"), ("🇩🇴 Dominican Republic", "DOM"), ("🇩🇰 Denmark", "DNK"), ("🇩🇪 Germany", "DEU"), ("🇨🇿 Czech Republic", "CZE"), ("🇨🇾 Cyprus", "CYP"), ("🇨🇺 Cuba", "CUB"), ("🇨🇷 Costa Rica", "CRI"), ("🇨🇴 Colombia", "COL"), ("🇨🇳 China", "CHN"), ("🇨🇲 Cameroon", "CMR"), ("🇨🇱 Chile", "CHL"), ("🇨🇮 Cote d'Ivoire", "CIV"), ("🇨🇭 Switzerland", "CHE"), ("🇨🇬 Congo", "COG"), ("🇨🇩 Democratic Republic of the Congo", "COD"), ("🇨🇦 Canada", "CAN"), ("🇧🇾 Belarus", "BLR"), ("🇧🇼 Botswana", "BWA"), ("🇧🇷 Brazil", "BRA"), ("🇧🇴 Bolivia", "BOL"), ("🇧🇳 Brunei", "BRN"), ("🇧🇯 Benin", "BEN"), ("🇧🇭 Bahrain", "BHR"), ("🇧🇬 Bulgaria", "BGR"), ("🇧🇪 Belgium", "BEL"), ("🇧🇩 Bangladesh", "BGD"), ("🇧🇦 Bosnia and Herzegovina", "BIH"), ("🇦🇿 Azerbaijan", "AZE"), ("🇦🇺 Australia", "AUS"), ("🇦🇹 Austria", "AUT"), ("🇦🇷 Argentina", "ARG"), ("🇦🇴 Angola", "AGO"), ("🇦 Netherlands Antilles", "ANT"), ("🇦🇲 Armenia", "ARM"), ("🇦🇱 Albania", "ALB"), ("🇦🇪 United Arab Emirates", "ARE") ] def find_electricity_mix(code: str): # TODO: Maybe more optimal to construct database at the beginning of the app # in the same fashion as find_model res = [] with open(PATH) as fd: csv = DictReader(fd) for row in csv: res += [float(row[code])] return res