[英]Write data from multiple input CSV file to a single CSV in column format
I'm trying to 我试图
loop over multiple csv files, 循环多个csv文件,
extract information from them 从他们那里提取信息
I take the information: 我得到的信息是:
Name, Date, Time, Test, Navg, Percent
名称,日期,时间,测试,导航,百分比
for each row. 每行。
I have tried to do it, however I have the problems: 我已经尝试过这样做,但是有一些问题:
It writes each new file to the a new row underneath(I do want it underneath, but with each word in a column. 它将每个新文件写到下面的新行中(我确实希望它在下面,但每个单词都在列中。
b = open('C:\\Users\\AClayton\\Desktop\\Data.csv', 'a') a = csv.writer(b,delimiter='\\t',lineterminator='\\n') a.writerows((Name, Date, Time, Test, Navg, Percent)) b.close()
Note the file has been read and the data extracted in earlier code. 请注意,文件已被读取,数据已在较早的代码中提取。
writerows
interpretes the input argument as a list of rows, hence each item in your tuple is written into a separate row. writerows
将输入参数解释为行列表,因此元组中的每个项目都被写入单独的行中。 Using writerow
should write it into a single row. 使用
writerow
应该将其写入一行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.