-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata_import.py
51 lines (39 loc) · 2.16 KB
/
data_import.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
import time
from app.import_scripts import incidents_data_import, citizens_data_import, create_indexes
from argparse import ArgumentParser
parser = ArgumentParser()
parser.add_argument('input_files', nargs='+', help='The input files to parse')
args = parser.parse_args()
start = time.time()
for input_file in args.input_files:
print(f"Processing file {input_file}")
if input_file.endswith('abandoned-vehicles.csv'):
incidents_data_import.import_abandoned_vehicles(input_file=input_file)
elif input_file.endswith('alley-lights-out.csv'):
incidents_data_import.import_alley_lights_out_or_street_lights_all_out(input_file=input_file, street_lights=False)
elif input_file.endswith('garbage-carts.csv'):
incidents_data_import.import_garbage_carts(input_file=input_file)
elif input_file.endswith('graffiti-removal.csv'):
incidents_data_import.import_graffiti(input_file=input_file)
elif input_file.endswith('pot-holes-reported.csv'):
incidents_data_import.import_potholes(input_file=input_file)
elif input_file.endswith('rodent-baiting.csv'):
incidents_data_import.import_rodent_baiting(input_file=input_file)
elif input_file.endswith('sanitation-code-complaints.csv'):
incidents_data_import.import_sanitation_complaints(input_file=input_file)
elif input_file.endswith('tree-debris.csv'):
incidents_data_import.import_tree_debris(input_file=input_file)
elif input_file.endswith('tree-trims.csv'):
incidents_data_import.import_tree_trims(input_file=input_file)
elif input_file.endswith('street-lights-all-out.csv'):
incidents_data_import.import_alley_lights_out_or_street_lights_all_out(input_file=input_file, street_lights=True)
elif input_file.endswith('street-lights-one-out.csv'):
incidents_data_import.import_street_lights_one_out(input_file=input_file)
else:
print(f"File '{input_file}' cannot be processed, skipping.")
print("Generating citizens and up-votes")
citizens_data_import.create_up_votes()
print("Creating Indexes")
create_indexes.create_indexes()
end = time.time()
print(f"Finished importing datasets, took {(end - start):.2f} seconds")