问题描述
我想以一种方式清除数据,如果某行超出某些列,则应将其删除
解决方法
下面的代码可能有帮助。
number_of_column=3
with open("test.csv","r") as f:
with open("out.csv","w") as f1:
line=f.readline()
while line:
if len(line.split(","))<=number_of_column:
f1.write(line)
line=f.readline()