Skip to content

Instantly share code, notes, and snippets.

@theDreamer911
Created June 22, 2022 07:13
Show Gist options
  • Save theDreamer911/35f9bb5714ec20f7ef305320d3f07020 to your computer and use it in GitHub Desktop.
Save theDreamer911/35f9bb5714ec20f7ef305320d3f07020 to your computer and use it in GitHub Desktop.
import pandas as pd
def country_info(country):
df_country = pd.read_html("https://tradingeconomics.com/matrix")[0]
info = df_country.loc[df_country["Country"] == country]
country_check = (df_country[df_country["Country"] == country]).all(1).any()
## Use for creating country.txt (List for all available country)
# with open("country.txt", "w") as f:
# f.write(f"{df_country.Country.values}\n")
if country_check == True:
info = df_country.loc[df_country["Country"] == country]
for col in info:
print(f"{info[col].name}: {info[col].values[0]}")
else:
print(f"Country not found, read country.txt for more information")
return [(f"{info[col].name}: {info[col].values[0]}") for col in info]
country = input("Country want to search: ")
country_info(country)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment