-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
98 lines (90 loc) · 2.2 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
import comtrade_manager as cm
import xlrd
years = "201801-201908"
dict_countries_reporter = {
40: "austria",
112: "belarus",
56: "belgium",
100: "bulgaria",
191: "croatia",
196: "cyprus",
203: "czechia",
208: "denmark",
233: "estonia",
246: "finland",
251: "france",
276: "germany",
300: "greece",
348: "hungary",
352: "iceland",
372: "ireland",
381: "italy",
428: "latvia",
440: "lithuania",
442: "luxembourg",
470: "malta",
528: "netherlands",
579: "norway",
616: "poland",
620: "portugal",
642: "romania",
643: "russian federation",
703: "slovakia",
705: "slovenia",
724: "spain",
752: "sweden",
757: "switzerland",
792: "turkey",
826: "united kingdom"
}
dict_countries_partner = {
40: "austria",
112: "belarus",
56: "belgium",
100: "bulgaria",
191: "croatia",
196: "cyprus",
203: "czechia",
208: "denmark",
233: "estonia",
246: "finland",
251: "france",
276: "germany",
300: "greece",
348: "hungary",
352: "iceland",
372: "ireland",
381: "italy",
428: "latvia",
440: "lithuania",
442: "luxembourg",
470: "malta",
528: "netherlands",
579: "norway",
616: "poland",
620: "portugal",
642: "romania",
643: "russian federation",
703: "slovakia",
705: "slovenia",
724: "spain",
752: "sweden",
757: "switzerland",
792: "turkey",
826: "united kingdom"
}
products = xlrd.open_workbook('data\HS4_codes.xlsx').sheet_by_index(0).col_values(0, 1)
product_list = [f"{i:02d}" for i in range(1, 100) if i != 98]
to_remove_products = [i[0:2] for i in products]
product_list = [i for i in product_list
if i not in list(set(to_remove_products))] + products
for k in dict_countries_reporter:
print(f"{dict_countries_reporter[k]}_{years}")
cm.download_trade_data(
filename=f"{dict_countries_reporter[k]}_{years}",
period=years,
frequency="M",
reporter=k,
partner=list(dict_countries_partner),
product=product_list
)