Function to export *.comm files
Created by: JakHolzer
Merge request reports
Activity
Filter activity
4 :arg string - string to fill 5 :arg total_lenght - length of the final string 6 :return string of the lenght of total_lenght 7 """ 8 white_spaces = " " * total_lenght 9 return_string = white_spaces[: -len(str(string))] + str(string) 10 return return_string 11 12 13 def export_comm(data, path): 14 """exports data in the *.comm format 15 :param path: path to file + name 16 :arg data - data to export, is dict after peak fitting 17 """ 18 19 if data["meta"]["indices"] == "hkl": Created by: ivan-usov
This code needs to be deduplicated.
if data["meta"]["indices"] == "hkl": extension = ".comm" elif data["meta"]["indices"] == "real": extension = ".incomm" with open(str(path + extension), "w") as out_file: for keys in data["Measurements"]: if extension == ".comm": meas_number_str = fill_string(keys[1:], 6) ... else: meas_number_str = fill_string(keys[1:], 4) ... etc.
Or something like that, probably the final form will be different depending on the approach you choose with the string interpolation.
Please register or sign in to reply