I have to csv files. The first looks like this:
The second contains a list of IP:
139.15.250.196
139.15.5.176
I'd like to check if any given IP in from the first file is in the second file. This seams to work (please correct or provide hints if my code is broken) but the issue is that the first file contains many duplicate values e.g. 10.0.0.1 may appear x times and I was not able to find a way to remove duplicates. Could you please assist me or guide ?
import csv
filename = 'ip2.csv'
with open(filename) as f:
reader = csv.reader(f)
ip = []
for row in reader:
ip.append(row[0])
filename = 'bonk_https.csv'
with open(filename) as f:
reader = csv.reader(f)
ip_ext = []
for row in reader:
ip_ext.append(row[0])
for a in ip:
if a in ip_ext:
print(a)