-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdatabase_downloader.py
58 lines (50 loc) · 1.91 KB
/
database_downloader.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
"""This module will download and unzip county dataframe files, and place
them in their respective directories"""
import time
from .helpers import downloader, gzipconverter
from .logger import logger
import os
DOWNLOAD_DICT = {
"sarasota": [
"https://www.sc-pa.com/downloads/SCPA_Parcels_Sales_CSV.zip",
"https://www.sc-pa.com/downloads/SCPA_Detailed_Data.zip",
],
"manatee": [
"https://www.manateepao.gov/data/manatee_ccdf.zip",
"https://www.manateepao.gov/data/subdivisions_in_manatee.csv",
],
"charlotte": [
"https://www.ccappraiser.com/downloads/charlotte.zip",
"https://www.ccappraiser.com/downloads/condominiums.xlsx",
"https://www.ccappraiser.com/downloads/subdivisions.xlsx",
],
}
FILES_TO_KEEP = {
"sarasota": ["Sarasota.csv", "SubDivisionIndex.txt"],
"manatee": ["manatee_ccdf.csv", "subdivisions_in_manatee.csv"],
"charlotte": ["cd.txt", "condominiums.xlsx", "subdivisions.xlsx"],
}
def main(download_dict: dict, files_to_keep: dict) -> None:
"""
Downloads all given county dataframes.
Args:
download_dict: dictionary containing County as the keys,
and a list of download urls as the values
"""
logger.info("Starting download process...")
download_object = downloader.Downloader(download_dict, files_to_keep)
download_object.download()
logger.info("Download process completed.")
logger.info("Starting GZIP conversion process...")
file_path_list = gzipconverter.GZIPConverter.get_dataframe_file_paths()
gzipconverter.GZIPConverter.convert_files_to_gzip(file_path_list)
logger.info("GZIP conversion process completed.")
if __name__ == "__main__":
logger.info("Starting program...")
start = time.time()
main(DOWNLOAD_DICT, FILES_TO_KEEP)
end = time.time()
logger.info(
"Program completed successfully. Time elapsed: %.2f seconds.",
end - start,
)