import csv, os





def match_stars(filename):

    match_to = []
    match_with = []
    star_data = []

    if "aligned_output.csv" in os.listdir(os.getcwd()):
        os.remove("aligned_output.csv")

    output = open("aligned_output.csv", 'a')

    with open(filename, 'r') as infile:
        reader = csv.reader(infile)
        for row in reader:
            match_to.append(row[0])
            match_with.append(row[1])
            star_data.append(row[2:])
    infile.close()

    for i in match_with:
        if i in match_to:
            print("Matched {}!".format(i))
            star_data_single = star_data[int(match_with.index(i))]
            star_data_single_formatted = ",".join(str(z) for z in star_data_single)
            output.write("{},{}\n".format(i, star_data_single_formatted))
        else:
            output.write("\n")

    output.close()










def initialization():

    print("\n\n\nPlease create a .csv file with the list of stars you would like to align your outputs to"
          "in the first column, and your outputs in the second+ columns.  The script will match the outputs with"
          "the list in the first column.  No header is required.\n\nPlease enter your .csv filename:")
    csv_name = input(">>> ")
    match_stars(filename=str(csv_name))






initialization()
@@ -477,16 +477,56 @@
 lose()%0A%0A
+    matched_val = 0%0A    missed_val = 0%0A%0A
     for 
@@ -536,20 +536,18 @@
 n match_
-with
+to
 :%0A      
@@ -554,34 +554,36 @@
   if i in match_
-to
+with
 :%0A            pr
@@ -587,16 +587,20 @@
  print(%22
+%5B~%5D 
 Matched 
@@ -602,26 +602,72 @@
 ched %7B%7D!
-%22.format(i
+ (%7B%7D + %7B%7D)%22.format(i, i, match_with%5Bmatch_with.index(i)%5D
 ))%0A     
@@ -898,43 +898,243 @@
     
-else:%0A            output.write(%22%5Cn%22
+    matched_val += 1%0A        else:%0A            print(%22%5BX%5D Failed to find %7B%7D!%22.format(i))%0A            output.write(%22%7B%7D,%22%22%5Cn%22.format(i))%0A            missed_val += 1%0A%0A    print(%22%5CnMatched %7B%7D%5CnMissed %7B%7D%5Cn%5Cn%22.format(matched_val, missed_val)
 )%0A%0A 
@@ -1583,24 +1583,25 @@
 )%0A%0A%0A%0A%0A%0A%0Ainitialization()
+%0A

Update Align_Stars.py