-
Notifications
You must be signed in to change notification settings - Fork 0
/
nsf_awards.py
49 lines (40 loc) · 1.73 KB
/
nsf_awards.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
import os
from nsf_query import get_awards_csv
from datetime import datetime
default = 1976
current = datetime.now().year # grep all awards till current year
# Program list to be downloaded.
programs = {
"Applied Mathematics" : default,
"Computational Mathematics" : 1984,
"Analysis" : 1991,
"Probability" : default,
"Statistics" : default,
"Algebra and Number Theory" : default,
"Topology" : default,
"Mathematical Biology" : 2001,
"Geometric Analysis" : default,
"Combinatorics" : 2006,
"Foundations" : default
}
for program, start_year in programs.items():
for year in range(start_year, current + 1):
print( "downloading " + program + " " + str(year) )
cur_dir = os.path.dirname(__file__)
prog_dir = program.replace(" ", "-")
target_file = os.path.join(os.path.join(cur_dir, prog_dir), "Awards-" + program.replace(" ", "-") +"-" + str(year) + ".csv")
if os.path.exists(target_file) and year < current:
print( "file exists for " + program + " " + str(year) +"\n" )
else:
out = get_awards_csv(program, year)
if out == 0:
print( "update needed, the download is completed for " + program + " " + str(year) +"\n" )
elif out == 1:
print( "update is not needed, the download is completed for " + program + " " + str(year) +"\n")
elif out == 2:
print(" creating new file, the download is completed for " + program + " " + str(year) +"\n")
else:
print("downloading issue, awards not downloaded.")
# clean the directory
if os.path.exists("Awards.csv"):
os.remove("Awards.csv")