📜  删除csv文件python代码示例中的重复行

📅  最后修改于: 2022-03-11 14:45:27.543000             🧑  作者: Mango

代码示例1
# credit to the Stack Overflow user in the source link

with open('file_with_duplicates.csv','r') as in_file, open('ouput.csv','w') as out_file:
  
    seen = set() # set for fast O(1) amortized lookup
    
    for line in in_file:
        if line in seen: 
          continue # skip duplicate

        seen.add(line)
        out_file.write(line)