Skip to content

Commit f87304c

Browse files
authored
Update download.py
1 parent 80eae74 commit f87304c

1 file changed

Lines changed: 9 additions & 14 deletions

File tree

  • statvar_imports/crdc/instructional_wifi_devices

statvar_imports/crdc/instructional_wifi_devices/download.py

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@
1919
logging.StreamHandler()
2020
]
2121
)
22+
OUTPUT_DIR = Path("input_files")
23+
# Create the output directory if it doesn't exist
24+
try:
25+
OUTPUT_DIR.mkdir(exist_ok=True)
26+
logging.info(f"Output directory created/verified: {OUTPUT_DIR.resolve()}")
27+
except Exception as e:
28+
logging.fatal(f"FATAL: Could not create output directory {OUTPUT_DIR.resolve()}. Exiting. Error: {e}")
29+
exit(1)
2230

2331
# --- Configuration ---
2432
BASE_URL = "https://civilrightsdata.ed.gov/assets/ocr/docs/"
@@ -53,19 +61,6 @@ def generate_year_strings(start_year=2020):
5361

5462
YEAR_STRINGS = generate_year_strings()
5563

56-
OUTPUT_DIR = Path("input_files")
57-
58-
# Create the output directory if it doesn't exist
59-
try:
60-
OUTPUT_DIR.mkdir(exist_ok=True)
61-
logging.info(f"Output directory created/verified: {OUTPUT_DIR.resolve()}")
62-
except Exception as e:
63-
logging.fatal(f"FATAL: Could not create output directory {OUTPUT_DIR.resolve()}. Exiting. Error: {e}")
64-
exit(1)
65-
66-
logging.info(f"Checking for data from academic years (newest first): {', '.join(YEAR_STRINGS)}")
67-
68-
6964
def get_full_year(year_string):
7065
"""
7166
Derives the full year (e.g., 2024 from '2023-24') for the YEAR column.
@@ -155,4 +150,4 @@ def process_crdc_data(year_string):
155150
# Be polite to the server by adding a small delay between large downloads
156151
time.sleep(2)
157152

158-
logging.info("\nAll tasks complete.")
153+
logging.info("\nAll tasks complete.")

0 commit comments

Comments
 (0)