![](/img/trans.png)
[英]Trying to append csv into another csv AS A ROW but I am getting this AttributeError: '_io.TextIOWrapper' object has no attribute 'writerows'
[英]Why do I keep getting the error “AttributeError: '_io.TextIOWrapper' object has no attribute 'writerows” when using csv module?
我导入了CSV,文档告诉我的操作方式导致失败。
这是有问题的代码。
outfile = open("D:/stock_information/processed data/standard_deviant.csv", "w")
write_outfile = csv.writer(outfile)
for i in range(len(all_standard_deviant_info)):
outfile.writerows(all_standard_deviant_info[i][0])
outfile.writerows(all_standard_deviant_info[i][1])
有谁知道为什么说.writerows不存在?
您需要使用
write_outfile.writerows(all_standard_deviant_info[i][0])
因为outfile
只是一个文件对象,而不是csv.writer
的对象。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.