import csv def run_import(): print('running') allansList = '/Users/rshield/Documents/THE_ORCHARD/KNR/MIGRATION/CONTRIBUTOR_CHECK/allansList.csv' uuidList = '/Users/rshield/Documents/THE_ORCHARD/KNR/MIGRATION/CONTRIBUTOR_CHECK/sortedUniqUUIDS.csv' allansHeader = '\ufeffEXTERNALID' uuidHeader = 'EXTERNALID' with open('resuls.csv', 'w') as resultsFile: resultsWriter = csv.writer(resultsFile) a = [] b = [] with open(allansList, 'r') as allans, open(uuidList, 'r') as uuids: allansReader = csv.DictReader(allans, delimiter=',', quotechar='"') uuidReader = csv.DictReader(uuids, delimiter=',', quotechar='"') for uuidRow in uuidReader: ip = uuidRow[uuidHeader] contributor = uuidRow['UUID'] a.append({'ip':ip, 'uuid': contributor.strip('"')}) # print(f"-{ip}-{contributor}") for fullRow in allansReader: fullId = fullRow[allansHeader] b.append(fullId) for x in a: for needle in b: if x['ip'] == needle: resultsWriter.writerow([needle.strip('"'), x['uuid'].strip('"')]) def getContents(filepath, header): with open(filepath, 'r') as f: reader = csv.DictReader(f, delimiter=',', quotechar='"') with open('/Users/rshield/Documents/THE_ORCHARD/KNR/MIGRATION/CONTRIBUTOR_CHECK/sortedUniqUUIDS.csv', 'r') as uuids: uuidReader = csv.DictReader(uuids, delimiter=',', quotechar='"') for row in uuidReader: needle = row['EXTERNALID'] uuid = row['UUID'] for r in reader: haystack = r['\ufeffEXTERNALID'] print(f"{needle} - {haystack}") def openFile(filepath, header): with open(filepath, 'r') as f: reader = csv.DictReader(f, delimiter=',', quotechar='"') for row in reader: print(row[header]) if __name__ == "__main__": run_import()