1# credit to the Stack Overflow user in the source link
2
3with open('file_with_duplicates.csv','r') as in_file, open('ouput.csv','w') as out_file:
4
5 seen = set() # set for fast O(1) amortized lookup
6
7 for line in in_file:
8 if line in seen:
9 continue # skip duplicate
10
11 seen.add(line)
12 out_file.write(line)