Python如何批量读取CSV文件并写入TXT?
1个回答
展开全部
直接用python 的 csv 模块即可。用DictReader类,转换成迭代对象更容易操作。
import csv
with open("1.csv") as cfile:
reader = csv.DictReader(cfile)
f = open("A.txt", "w")
for row in reader:
if row.get("BBB") == "OK":
print row.get("AAA")
f.write(row.get("AAA") + "\n")
import csv
with open("1.csv") as cfile:
reader = csv.DictReader(cfile)
f = open("A.txt", "w")
for row in reader:
if row.get("BBB") == "OK":
print row.get("AAA")
f.write(row.get("AAA") + "\n")
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询