straight_length, distance_from_stem_apical, angle, convexfull_area) col_name = [ "file_path", "exec_times", "roi_id", "types", "curve_length", "straight_length", "distance_from_stem_apical", "angle", "convexfull_area" ] csv_path = os.path.join(get_file_info()[0], get_file_info()[1] + "_analyze.csv") # ファイルに内容がある場合は何もせず, 内容がないときだけカラムを書き込む with open(csv_path, "a") as f1: with open(csv_path, "r") as f2: s = f2.read() if s == "": with open(csv_path, "w") as f3: writer = csv.writer(f3) writer.writerow(col_name) # 上書きモードで値を書き込む with open(csv_path, "a") as f: writer = csv.writer(f) writer.writerows(for_csv_row) # saveしたあとにoverlayに書き込んで線を青色に変える。 save_roi_set(imp=IJ.getImage()) # table上に表示する op = Opener() op.openTable(csv_path)