I have 2 CSV files i'm trying to compare "Email" column for match, the below code is fine for comparing but when it iterate through the lines in the file it will print "No Match" after checking every line, I need it to only print "No Match" only after it checks all rows and didn't find match then print "No Match" in the file
could you please help a beginner with that?
with open("new.csv", "r") as csv_file1:
csv_reader = csv.DictReader(csv_file1, delimiter=",", quotechar='"')
for file1Line in csv_reader:
with open("old.csv", "r") as csv_file2:
csv_reader = csv.DictReader(csv_file2, delimiter=",", quotechar='"')
for file2Line in csv_reader:
if (
file1Line["User ID/Email (Required)"]
== file2Line["User ID/Email (Required)"]
):
print("Match found:")
else:
print("no match")