您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

如何在Python中合并200个csv文件

如何在Python中合并200个csv文件

正如ghostdog74所说的,但是这次有标题

fout=open("out.csv","a")
# first file:
for line in open("sh1.csv"):
    fout.write(line)
# Now the rest:    
for num in range(2,201):
    f = open("sh"+str(num)+".csv")
    f.next() # skip the header
    for line in f:
         fout.write(line)
    f.close() # not really needed
fout.close()
python 2022/1/1 18:52:28 有324人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶