import string # ##### Change the variables in the following section to adapt the script to your situation #### field_name_to_format = ["NAME1","NAME2"] # What kind of formating do you need # 1. ALL UPPERCASE # 2. all lowercase # 3. Proper Case (first letter of each word capitalised) # 4. Sentence case (only first letter of entire string capitalised) formatting_type = 4; # #### ------------------------------------------------------------- #### #class that will handle the formating class Formatter(): def format(self, format_string,type): if type == 1: format_string = format_string.upper() if type == 2: format_string = format_string.lower() if type == 3: format_string = string.capwords(format_string) if type == 4: format_string = string.capwords(format_string,'. ') return format_string project_path = MMpy.Project.path() #Let's create a backup of the file we want to modified MMpy.File.copy(project_path + "MineralOccurrence.DAT",project_path + "MineralOccurrence.DAT.back") #Open the file input_file = MMpy.File(); if input_file.open(project_path + "MineralOccurrence.DAT") == False: sys.exit("Could not open input file: MineralOccurrence.DAT") #let's create a formatter object format_obj = Formatter() for field_name in field_name_to_format: #retrieve the field_id field_id = input_file.get_field_id(field_name) for i in range(1,input_file.records_count+1): # get the string and format it new_string = format_obj.format(input_file.get_str_field_value(field_id,i),formatting_type) # replace the old sting with the new formatted one. input_file.set_field_value(field_id,i,new_string) #close the input file input_file.close()