· 7 years ago · Nov 15, 2018, 12:00 PM
1import csv
2
3# this will pull out emails at index 10, with domains in blacklist
4# and add the remaining emails to a whitelist
5
6blacklist = ['gmail.com', 'yahoo.com']
7whiteLst = []
8
9with open('dummyData500.csv', 'r') as f:
10 data = csv.reader(f)
11 next(f)
12 for line in data:
13 email = line[10]
14 dls = email.split('@')
15 if dls[1] not in blacklist:
16 whiteLst.append(email)
17
18with open('clean.csv', 'w') as wf:
19 dataW = csv.writer(wf)
20 for i in whiteLst:
21 dataW.writerows(i)