@@ -16,6 +16,7 @@ def process_csv_to_fhir(incoming_message_body: dict) -> None:
1616 For each row of the csv, attempts to transform into FHIR format, sends a message to kinesis,
1717 and documents the outcome for each row in the ack file.
1818 """
19+ encoder = "utf-8" # default encoding
1920 try :
2021 interim_message_body = file_level_validation (incoming_message_body = incoming_message_body )
2122 except (InvalidHeaders , NoOperationPermissions , Exception ): # pylint: disable=broad-exception-caught
@@ -36,11 +37,11 @@ def process_csv_to_fhir(incoming_message_body: dict) -> None:
3637 row_count = process_rows (file_id , vaccine , supplier , file_key , allowed_operations ,
3738 created_at_formatted_string , csv_reader , target_disease )
3839 except Exception as error : # pylint: disable=broad-exception-caught
39- encoder = "cp1252"
40+ new_encoder = "cp1252"
4041 print (f"Error processing: { error } ." )
41- print (f"Encode error at row { row_count } with { encoding } . Switch to { encoder } " )
4242 # check if it's a decode error, ie error.args[0] begins with "'utf-8' codec can't decode byte"
4343 if error .args [0 ].startswith ("'utf-8' codec can't decode byte" ):
44+ print (f"Encode error at row { row_count } with { encoder } . Switch to { new_encoder } " )
4445 print (f"Detected decode error: { error .args [0 ]} " )
4546 # if we are here, re-read the file with correct encoding and ignore the processed rows
4647 # if error.args[0] == "'utf-8' codec can't decode byte 0xe9 in position 2996: invalid continuation byte":
0 commit comments