Added postprocessing for universe_map_file.py
This commit is contained in:
parent
dc4056c1ed
commit
18b6bee0a0
|
|
@ -33,6 +33,7 @@ class AFCMUniverseMapFile:
|
|||
self.mosaic_head = {}
|
||||
self.metadata = {}
|
||||
self.mosaic_file_list = {}
|
||||
self.mosaic_postprocess = {}
|
||||
|
||||
self.files = []
|
||||
|
||||
|
|
@ -41,9 +42,10 @@ class AFCMUniverseMapFile:
|
|||
self.optout_s3_connection = None
|
||||
self.optout_s3_bucket = None
|
||||
|
||||
self.final_rows = []
|
||||
self.cleaned_import_rows = []
|
||||
self.removed_row_count = 0
|
||||
self.processed_row_count = 0
|
||||
self.final_rows = []
|
||||
|
||||
# Watch for duplicates across files
|
||||
self.running_phone_numbers = {}
|
||||
|
|
@ -105,6 +107,9 @@ class AFCMUniverseMapFile:
|
|||
if 'files' in data:
|
||||
self.mosaic_file_list = data['files']
|
||||
|
||||
if 'postprocess' in data:
|
||||
self.mosaic_postprocess = data['postprocess']
|
||||
|
||||
return data
|
||||
|
||||
|
||||
|
|
@ -199,11 +204,41 @@ class AFCMUniverseMapFile:
|
|||
# Loop the files from the map
|
||||
for ufilename in self.mosaic_file_list:
|
||||
self.process_file(ufilename)
|
||||
|
||||
# Perform post-processing
|
||||
if len(self.mosaic_postprocess) is not 0:
|
||||
self.postprocessing()
|
||||
else:
|
||||
# copy self.cleaned_import_rows list to self.final_rows list
|
||||
self.final_rows = self.cleaned_import_rows[:]
|
||||
|
||||
# Run final steps
|
||||
self.write_final_file()
|
||||
self.write_stats_file()
|
||||
|
||||
|
||||
def postprocessing(self):
|
||||
"""
|
||||
postprocessing Performs actions for any postprocessing rules defined in the voterset map file
|
||||
"""
|
||||
|
||||
# structure in the map file
|
||||
# "postprocess": {
|
||||
# "range": {
|
||||
# "start": 0,
|
||||
# "end": 10000
|
||||
# }
|
||||
# }
|
||||
|
||||
|
||||
# get list of keys from "postprocess"
|
||||
# if "range" exists,
|
||||
# get "start" and "end" keys
|
||||
# copy the range from cleaned_import_rows into final_rows
|
||||
|
||||
return
|
||||
|
||||
|
||||
def process_file(self, voterset_filename):
|
||||
"""
|
||||
process_file Process the file of the VoterSet
|
||||
|
|
@ -353,7 +388,7 @@ class AFCMUniverseMapFile:
|
|||
new_row['Cell_Phone'] = formatted_number
|
||||
|
||||
amplify_rows.append(new_row)
|
||||
self.final_rows.append(new_row)
|
||||
self.cleaned_import_rows.append(new_row)
|
||||
self.running_phone_numbers[formatted_number] = True
|
||||
|
||||
processing_time = time.time() - processing_time_start
|
||||
|
|
|
|||
Loading…
Reference in New Issue