-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
38 lines (29 loc) · 1.05 KB
/
main.py
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
"""
This is the main file to run the WorldBankDataDownloader.
"""
from src.utils.singleton_logger import SingletonLogger
from src.world_bank.data_downloader import WorldBankDataDownloader
def main():
"""
Main function to download data from the World Bank API.
:return: None
:rtype: None
"""
# Set up logging
logger = SingletonLogger().get_logger()
# Initialize the downloader
downloader = WorldBankDataDownloader()
# Get all country codes and indicator codes
country_codes = downloader.country_codes
indicator_codes = downloader.indicator_codes
# Download data for all countries and indicators
all_data = {}
for country_code in country_codes:
logger.info(f"Downloading data for country: {country_code}")
country_data = downloader.fetch_data_concurrently(country_code, indicator_codes)
all_data[country_code] = country_data
# Save the data to a file
downloader.save_data_to_file(all_data)
logger.info("Data download and save completed.")
if __name__ == "__main__":
main()