import pandas as pd from tkinter import Tk, filedialog # Function to upload a file and return its dataframe def upload_file(prompt): root = Tk() root.withdraw() # Hide the root window file_path = filedialog.askopenfilename(title=prompt) if file_path: return pd.read_csv(file_path) else: print("No file selected!") return None # Function to compare two lists and save the result def compare_and_save(list1, list2, output_file): # Find addresses in list1 that are not in list2 difference = pd.merge(list1, list2, indicator=True, how='outer').loc[lambda x: x['_merge'] == 'left_only'] difference.drop(columns=['_merge'], inplace=True) # Save the result to a new CSV file difference.to_csv(output_file, index=False) print(f"Result saved to {output_file}") def main(): print("Upload the first CSV file (list of addresses):") list1 = upload_file("Select the first CSV file") if list1 is None: return print("Upload the second CSV file:") list2 = upload_file("Select the second CSV file") if list2 is None: return output_file = "output_difference.csv" compare_and_save(list1, list2, output_file) if __name__ == "__main__": main()