使用python脚本删除csv文件中的重复条目 [英] Removing duplicate entries in a csv file using a python script
本文介绍了使用python脚本删除csv文件中的重复条目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是python的初学者。你能告诉我如何继续删除csv文件中的重复行
I m a beginner to python. Could you tell me how should i proceed to remove duplicate rows in a csv file
推荐答案
我是初学者到python 。你能告诉我如何继续删除csv文件中的重复行
I m a beginner to python. Could you tell me how should i proceed to remove duplicate rows in a csv file
如果你的csv文件中的信息顺序没关系,你可以将文件的每一行放入一个列表,将列表转换为一个集合,然后将列表写回文件。当您将列表转换为集合时,所有重复元素都会消失。
If the order of the information in your csv file doesn''t matter, you could put each line of the file into a list, convert the list into a set, and then write the list back into the file. When you convert the list to a set, all duplicate elements disappear.
展开 | 选择 | Wrap | 行号
此代码维护订单数据:
展开 | 选择 | Wrap | 行号
这是另一种方式使用bvdet的方法和csv模块来解决你的问题。
Here is another way to solve your problem using bvdet''s method and the csv module.
展开 | 选择 | Wrap < span class =codeDivider> | 行号
这篇关于使用python脚本删除csv文件中的重复条目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文