Hello, I'm enjoying learning python but then I come across some basic things that makes me stumped... I have 2 csv files and I want to see which ones are duplicates based on two criteria email, or telephone. The order of fields in both csv files are different. Here are a sample bogus data:
import csv bv = """NAME,BVADDRTELNO1,BVADDREMAIL Company1, 1234567788, [email protected] CompanyA, 1231234455, [email protected] CompanyC, 1011011111, [email protected] CompanyD, 2222222222, [email protected] """ site = """Company,Email,Phone "Company3","[email protected]","1234560000" "CompanyD","[email protected]","2222222222" "Company1","[email protected]","1234567788" """ bv = bv.upper() # This is just to make the data more homogeneous and detect duplicates more easily site = site.upper() bvreader = csv.DictReader(bv.splitlines(True)) sitelist = csv.DictReader(site.splitlines(True)) for row in sitelist: for line in bvreader: if row['EMAIL'] == line['BVADDREMAIL']: print line['NAME'], row['COMPANY'] #===== My questions are: Why nothing is being printed? Two rows should be printed right? What would be better for the outer loop, the bigger list or the small list? The biglist (bvreader) is under 2100 lines (244Kb) and the smaller list (sitelist) can be 20 lines or less. Thanks. Eduardo _______________________________________________ Tutor maillist - [email protected] http://mail.python.org/mailman/listinfo/tutor
