in microservices/extraction_service/src/utils/correct_key_value.py [0:0]
def data_transformation(input_dict):
'''
Function for data transformation
Input:
input_dict: input dictionary of extraction
Output:
input_dict: original dictionary
temp_dict: corrected dictionary
'''
try:
# get a copy of input dictionary
temp_dict = input_dict.copy()
# traverse through input_dict
for index, input_item in enumerate(input_dict):
# get input dictionary
corrected_dict = input_item.copy()
# check for string
corrected_dict = correction_script(corrected_dict, "convert_to_string")
# check for number
corrected_dict = correction_script(corrected_dict, "convert_to_number")
# check for noise
corrected_dict = correction_script(corrected_dict, "clean_value")
# check for upper to lower
corrected_dict = correction_script(corrected_dict, "upper_to_lower")
# check for lower to upper
corrected_dict = correction_script(corrected_dict, "lower_to_upper")
# check for multiple spaces
corrected_dict = correction_script(corrected_dict, "clean_multiple_space")
# check for date format
corrected_dict = correction_script(corrected_dict, "date_format")
# correct input dictionary
temp_dict[index] = corrected_dict
return input_dict, temp_dict
except Exception as e: # pylint: disable=broad-except
Logger.error(f"Error in the date tranformation postprocessing {e}")
Logger.error(e)
return None,None