diff --git a/app/aws/s3.py b/app/aws/s3.py index 7e3e4585a..7789d80ed 100644 --- a/app/aws/s3.py +++ b/app/aws/s3.py @@ -120,9 +120,13 @@ def extract_phones(job): phone_index = phone_index + 1 current_app.logger.info(f"PHONE INDEX IS NOW {phone_index}") current_app.logger.info(f"LENGTH OF ROW IS {len(row)}") - my_phone = row[phone_index] - my_phone = re.sub(r"[\+\s\(\)\-\.]*", "", my_phone) - phones[job_row] = my_phone + if phone_index <= len(row): + phones[job_row] = "Error: can't retrieve phone number" + current_app.logger.error("Corrupt csv file, missing columns job_id {job_id} service_id {service_id}") + else: + my_phone = row[phone_index] + my_phone = re.sub(r"[\+\s\(\)\-\.]*", "", my_phone) + phones[job_row] = my_phone job_row = job_row + 1 return phones